@wazo/sdk 0.39.15 → 0.40.1
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 +3 -1
- 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 +44 -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 +7 -6
- 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 +3 -1
- package/esm/types/domain/Phone/CTIPhone.d.ts.map +1 -1
- package/esm/types/domain/Phone/Phone.d.ts +13 -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 +52 -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 +3 -1
- 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 +96 -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 +4 -3
- 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 +3 -1
- package/lib/types/domain/Phone/CTIPhone.d.ts.map +1 -1
- package/lib/types/domain/Phone/Phone.d.ts +13 -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 +52 -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 +5 -1
- package/src/domain/Phone/Phone.ts +12 -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 +52 -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 +10 -9
- 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/lib/websocket-client.js
CHANGED
|
@@ -199,10 +199,9 @@ class WebSocketClient extends Emitter_1.default {
|
|
|
199
199
|
default:
|
|
200
200
|
}
|
|
201
201
|
};
|
|
202
|
-
this.socket.onerror = event => {
|
|
202
|
+
this.socket.onerror = (event) => {
|
|
203
203
|
logger.info('Wazo WS error', {
|
|
204
204
|
message: event.message,
|
|
205
|
-
// @ts-ignore
|
|
206
205
|
code: event.code,
|
|
207
206
|
readyState: event.target.readyState,
|
|
208
207
|
});
|
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wazo/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.40.1",
|
|
4
4
|
"description": "Wazo's JavaScript Software Development Kit.",
|
|
5
|
-
"main": "
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"types": "lib/types/index.d.ts",
|
|
6
7
|
"author": "Wazo (http://wazo.io)",
|
|
7
8
|
"maintainers": [
|
|
8
9
|
"Wazo Team <dev@wazo.io> (https://github.com/wazo-platform)"
|
|
@@ -13,6 +14,7 @@
|
|
|
13
14
|
"license": "MIT",
|
|
14
15
|
"homepage": "https://github.com/wazo-platform/wazo-js-sdk",
|
|
15
16
|
"files": [
|
|
17
|
+
"index.js",
|
|
16
18
|
"dist/*.js",
|
|
17
19
|
"src/**/*",
|
|
18
20
|
"esm/**/*",
|
|
@@ -39,21 +41,6 @@
|
|
|
39
41
|
"typecheck": "./node_modules/.bin/tsc --noEmit",
|
|
40
42
|
"prepublishOnly": "yarn build"
|
|
41
43
|
},
|
|
42
|
-
"exports": {
|
|
43
|
-
".": {
|
|
44
|
-
"import": {
|
|
45
|
-
"types": "./esm/types/index.d.ts",
|
|
46
|
-
"default": "./esm/index.mjs"
|
|
47
|
-
},
|
|
48
|
-
"require": {
|
|
49
|
-
"types": "./lib/types/index.d.ts",
|
|
50
|
-
"default": "./lib/index.js"
|
|
51
|
-
}
|
|
52
|
-
},
|
|
53
|
-
"./lib/": "./lib/",
|
|
54
|
-
"./lib/simple": "./lib/simple/index.js",
|
|
55
|
-
"./dist/wazo-sdk": "./dist/wazo-sdk.js"
|
|
56
|
-
},
|
|
57
44
|
"dependencies": {
|
|
58
45
|
"events": "^3.3.0",
|
|
59
46
|
"fstream": "^1.0.12",
|
|
@@ -84,7 +71,7 @@
|
|
|
84
71
|
"@types/jest": "^29.5.2",
|
|
85
72
|
"@types/jsrsasign": "^10.5.8",
|
|
86
73
|
"@types/node": "^20.4.0",
|
|
87
|
-
"@types/sdp-transform": "^2.4.
|
|
74
|
+
"@types/sdp-transform": "^2.4.9",
|
|
88
75
|
"@typescript-eslint/eslint-plugin": "^5.61.0",
|
|
89
76
|
"@typescript-eslint/parser": "^5.61.0",
|
|
90
77
|
"babel-core": "^7.0.0-bridge.0",
|
|
@@ -88,8 +88,7 @@ client.setToken(token);
|
|
|
88
88
|
describe('With correct API results', () => {
|
|
89
89
|
beforeEach(() => {
|
|
90
90
|
jest.resetModules();
|
|
91
|
-
|
|
92
|
-
global.fetch = jest.fn(() => Promise.resolve(mockedJson));
|
|
91
|
+
global.fetch = jest.fn(() => Promise.resolve(mockedJson)) as any;
|
|
93
92
|
});
|
|
94
93
|
|
|
95
94
|
describe('logIn test', () => {
|
|
@@ -102,13 +101,12 @@ describe('With correct API results', () => {
|
|
|
102
101
|
Authorization: `Basic ${Base64.encode(`${username}:${password}`)}`,
|
|
103
102
|
'Content-Type': 'application/json',
|
|
104
103
|
};
|
|
105
|
-
|
|
104
|
+
|
|
106
105
|
const result = await client.auth.logIn({
|
|
107
106
|
username,
|
|
108
107
|
password,
|
|
109
|
-
});
|
|
108
|
+
} as any) as any;
|
|
110
109
|
expect(result).toBeInstanceOf(Session);
|
|
111
|
-
// @ts-expect-error
|
|
112
110
|
expect(result.token).toBe(1);
|
|
113
111
|
expect(global.fetch).toBeCalledWith(`https://${server}/api/auth/${authVersion}/token`, {
|
|
114
112
|
method: 'post',
|
|
@@ -123,8 +121,7 @@ describe('With correct API results', () => {
|
|
|
123
121
|
describe('logOut test', () => {
|
|
124
122
|
it('should delete the specified token', async () => {
|
|
125
123
|
const oldToken = 123;
|
|
126
|
-
|
|
127
|
-
await client.auth.logOut(oldToken);
|
|
124
|
+
await client.auth.logOut(oldToken as any);
|
|
128
125
|
expect(global.fetch).toBeCalledWith(`https://${server}/api/auth/${authVersion}/token/${oldToken}`, {
|
|
129
126
|
method: 'delete',
|
|
130
127
|
body: null,
|
|
@@ -139,8 +136,7 @@ describe('With correct API results', () => {
|
|
|
139
136
|
describe('With unAuthorized API results', () => {
|
|
140
137
|
beforeEach(() => {
|
|
141
138
|
jest.resetModules();
|
|
142
|
-
|
|
143
|
-
global.fetch = jest.fn(() => Promise.resolve(mockedUnAuthorized));
|
|
139
|
+
global.fetch = jest.fn(() => Promise.resolve(mockedUnAuthorized)) as any;
|
|
144
140
|
});
|
|
145
141
|
|
|
146
142
|
describe('checkLogin test', () => {
|
|
@@ -162,8 +158,7 @@ describe('With unAuthorized API results', () => {
|
|
|
162
158
|
describe('With not found API results', () => {
|
|
163
159
|
beforeEach(() => {
|
|
164
160
|
jest.resetModules();
|
|
165
|
-
|
|
166
|
-
global.fetch = jest.fn(() => Promise.resolve(mockedNotFound));
|
|
161
|
+
global.fetch = jest.fn(() => Promise.resolve(mockedNotFound)) as any;
|
|
167
162
|
});
|
|
168
163
|
|
|
169
164
|
describe('fetchVoicemail test', () => {
|
|
@@ -198,19 +193,17 @@ describe('With not found API results', () => {
|
|
|
198
193
|
describe('With erroneous text API results', () => {
|
|
199
194
|
beforeEach(() => {
|
|
200
195
|
jest.resetModules();
|
|
201
|
-
|
|
202
|
-
global.fetch = jest.fn(() => Promise.resolve(mockedTextError));
|
|
196
|
+
global.fetch = jest.fn(() => Promise.resolve(mockedTextError)) as any;
|
|
203
197
|
});
|
|
204
198
|
|
|
205
199
|
it('throw an exception when the response is >= 500', async () => {
|
|
206
200
|
let error = null;
|
|
207
201
|
|
|
208
202
|
try {
|
|
209
|
-
// @ts-expect-error
|
|
210
203
|
await client.auth.logIn({
|
|
211
204
|
username,
|
|
212
205
|
password,
|
|
213
|
-
});
|
|
206
|
+
} as any);
|
|
214
207
|
} catch (e: any) {
|
|
215
208
|
error = e;
|
|
216
209
|
}
|
|
@@ -225,19 +218,17 @@ describe('With erroneous text API results', () => {
|
|
|
225
218
|
describe('With erroneous json API results', () => {
|
|
226
219
|
beforeEach(() => {
|
|
227
220
|
jest.resetModules();
|
|
228
|
-
|
|
229
|
-
global.fetch = jest.fn(() => Promise.resolve(mockedJsonError));
|
|
221
|
+
global.fetch = jest.fn(() => Promise.resolve(mockedJsonError)) as any;
|
|
230
222
|
});
|
|
231
223
|
|
|
232
224
|
it('throw an exception when the response is >= 500', async () => {
|
|
233
225
|
let error = null;
|
|
234
226
|
|
|
235
227
|
try {
|
|
236
|
-
// @ts-expect-error
|
|
237
228
|
await client.auth.logIn({
|
|
238
229
|
username,
|
|
239
230
|
password,
|
|
240
|
-
});
|
|
231
|
+
} as any);
|
|
241
232
|
} catch (e: any) {
|
|
242
233
|
error = e;
|
|
243
234
|
}
|
|
@@ -4,18 +4,15 @@ jest.mock('sip.js/lib/platform/web/transport');
|
|
|
4
4
|
jest.mock('sip.js/lib/api/user-agent', () => ({
|
|
5
5
|
start: () => {},
|
|
6
6
|
UserAgent: class UserAgent {
|
|
7
|
-
|
|
8
|
-
static makeURI = () => {};
|
|
7
|
+
static makeURI: () => null = () => null;
|
|
9
8
|
|
|
10
|
-
// @ts-ignore
|
|
11
9
|
start = () => {};
|
|
12
10
|
|
|
13
11
|
transport = {};
|
|
14
12
|
},
|
|
15
13
|
}));
|
|
16
14
|
|
|
17
|
-
|
|
18
|
-
const client = new WebRTCClient({});
|
|
15
|
+
const client = new WebRTCClient({} as any, null, undefined);
|
|
19
16
|
|
|
20
17
|
describe('WebRTC client', () => {
|
|
21
18
|
it('should compute muted/unmuted state', async () => {
|
|
@@ -65,14 +62,11 @@ describe('WebRTC client', () => {
|
|
|
65
62
|
},
|
|
66
63
|
},
|
|
67
64
|
};
|
|
68
|
-
|
|
69
|
-
expect(client.isAudioMuted(mutedSession)).toBeTruthy();
|
|
70
|
-
|
|
71
|
-
expect(client.isAudioMuted(
|
|
72
|
-
|
|
73
|
-
expect(client.isAudioMuted(unMutedSession)).toBeFalsy();
|
|
74
|
-
// @ts-expect-error
|
|
75
|
-
expect(client.isAudioMuted(oldKindUnmuted)).toBeFalsy();
|
|
65
|
+
|
|
66
|
+
expect(client.isAudioMuted(mutedSession as any)).toBeTruthy();
|
|
67
|
+
expect(client.isAudioMuted(oldKindMuted as any)).toBeTruthy();
|
|
68
|
+
expect(client.isAudioMuted(unMutedSession as any)).toBeFalsy();
|
|
69
|
+
expect(client.isAudioMuted(oldKindUnmuted as any)).toBeFalsy();
|
|
76
70
|
});
|
|
77
71
|
});
|
|
78
72
|
describe('changeAudioInputDevice', () => {
|
|
@@ -131,27 +125,21 @@ describe('changeAudioInputDevice', () => {
|
|
|
131
125
|
},
|
|
132
126
|
});
|
|
133
127
|
it('should change the audio input track if the provided id is different', async () => {
|
|
134
|
-
|
|
135
|
-
client.setMediaConstraints(constraints);
|
|
128
|
+
client.setMediaConstraints(constraints as any);
|
|
136
129
|
expect(client.getAudioDeviceId()).toBe(defaultId);
|
|
137
|
-
|
|
138
|
-
const result = await client.changeAudioInputDevice(deviceId, session);
|
|
130
|
+
const result = await client.changeAudioInputDevice(deviceId, session as any);
|
|
139
131
|
expect(result).toBeTruthy();
|
|
140
132
|
});
|
|
141
133
|
it('should NOT change the audio input track if the provided id is the same', async () => {
|
|
142
|
-
|
|
143
|
-
client.setMediaConstraints(constraints);
|
|
134
|
+
client.setMediaConstraints(constraints as any);
|
|
144
135
|
expect(client.getAudioDeviceId()).toBe(defaultId);
|
|
145
|
-
|
|
146
|
-
const result = await client.changeAudioInputDevice(defaultId, session);
|
|
136
|
+
const result = await client.changeAudioInputDevice(defaultId, session as any);
|
|
147
137
|
expect(result).toBeFalsy();
|
|
148
138
|
});
|
|
149
139
|
it('should change the audio input track if the provided id is the same and force param is TRUE', async () => {
|
|
150
|
-
|
|
151
|
-
client.setMediaConstraints(constraints);
|
|
140
|
+
client.setMediaConstraints(constraints as any);
|
|
152
141
|
expect(client.getAudioDeviceId()).toBe(defaultId);
|
|
153
|
-
|
|
154
|
-
const result = await client.changeAudioInputDevice(defaultId, session, true);
|
|
142
|
+
const result = await client.changeAudioInputDevice(defaultId, session as any, true);
|
|
155
143
|
expect(result).toBeTruthy();
|
|
156
144
|
});
|
|
157
145
|
describe('setVideoInputDevice', () => {
|
package/src/api/auth.ts
CHANGED
|
@@ -17,8 +17,8 @@ type LoginParams = {
|
|
|
17
17
|
};
|
|
18
18
|
|
|
19
19
|
type SendResetPasswordArgs = {
|
|
20
|
-
username
|
|
21
|
-
email
|
|
20
|
+
username?: string,
|
|
21
|
+
email?: string,
|
|
22
22
|
};
|
|
23
23
|
|
|
24
24
|
export interface AuthD {
|
|
@@ -166,9 +166,6 @@ export default ((client: ApiRequester, baseUrl: string): AuthD => ({
|
|
|
166
166
|
sendResetPasswordEmail: ({
|
|
167
167
|
username,
|
|
168
168
|
email,
|
|
169
|
-
}: {
|
|
170
|
-
username: string | null | undefined;
|
|
171
|
-
email: string | null | undefined;
|
|
172
169
|
}) => {
|
|
173
170
|
const body: any = {};
|
|
174
171
|
|
package/src/api/call-logd.ts
CHANGED
|
@@ -2,10 +2,10 @@ import ApiRequester from '../utils/api-requester';
|
|
|
2
2
|
import CallLog from '../domain/CallLog';
|
|
3
3
|
|
|
4
4
|
export interface CallLogD {
|
|
5
|
-
search: (search: string, limit
|
|
6
|
-
searchBy: (field: string, value: string, limit
|
|
5
|
+
search: (search: string, limit?: number) => Promise<Array<CallLog>>;
|
|
6
|
+
searchBy: (field: string, value: string, limit?: number) => Promise<Array<CallLog>>;
|
|
7
7
|
listCallLogs: (offset?: number, limit?: number) => Promise<Array<CallLog>>;
|
|
8
|
-
listDistinctCallLogs: (offset: number, limit
|
|
8
|
+
listDistinctCallLogs: (offset: number, limit?: number, distinct?: string) => Promise<Array<CallLog>>;
|
|
9
9
|
listCallLogsFromDate: (from: Date, number: string) => Promise<Array<CallLog>>;
|
|
10
10
|
}
|
|
11
11
|
|
package/src/api/chatd.ts
CHANGED
|
@@ -1,35 +1,22 @@
|
|
|
1
1
|
import ApiRequester from '../utils/api-requester';
|
|
2
|
-
import type { UUID } from '../domain/types';
|
|
2
|
+
import type { PresenceResponse, UUID } from '../domain/types';
|
|
3
3
|
import Profile from '../domain/Profile';
|
|
4
4
|
import ChatRoom from '../domain/ChatRoom';
|
|
5
5
|
import type { ChatUser, ChatMessageListResponse } from '../domain/ChatMessage';
|
|
6
6
|
import ChatMessage from '../domain/ChatMessage';
|
|
7
7
|
|
|
8
|
-
export type PresenceResponse = {
|
|
9
|
-
lines: Array<{
|
|
10
|
-
id: number;
|
|
11
|
-
state: string;
|
|
12
|
-
}>;
|
|
13
|
-
sessions: Array<{
|
|
14
|
-
mobile: boolean;
|
|
15
|
-
uuid: string;
|
|
16
|
-
}>;
|
|
17
|
-
state: string;
|
|
18
|
-
status: string;
|
|
19
|
-
user_uuid: string;
|
|
20
|
-
};
|
|
21
8
|
type PresenceListResponse = {
|
|
22
9
|
filtered: number;
|
|
23
10
|
total: number;
|
|
24
11
|
items: Array<PresenceResponse>;
|
|
25
12
|
};
|
|
26
13
|
type GetMessagesOptions = {
|
|
27
|
-
direction
|
|
28
|
-
limit
|
|
29
|
-
order
|
|
30
|
-
offset
|
|
31
|
-
search
|
|
32
|
-
distinct
|
|
14
|
+
direction?: string;
|
|
15
|
+
limit?: number;
|
|
16
|
+
order?: string;
|
|
17
|
+
offset?: string;
|
|
18
|
+
search?: string;
|
|
19
|
+
distinct?: string;
|
|
33
20
|
};
|
|
34
21
|
|
|
35
22
|
export interface ChatD {
|
|
@@ -43,7 +30,7 @@ export interface ChatD {
|
|
|
43
30
|
createRoom: (name: string, users: Array<ChatUser>) => Promise<ChatRoom>;
|
|
44
31
|
getRoomMessages: (roomUuid: string, params?: GetMessagesOptions) => Promise<Array<ChatMessage>>;
|
|
45
32
|
sendRoomMessage: (roomUuid: string, message: ChatMessage) => Promise<ChatMessage>;
|
|
46
|
-
getMessages: (options: GetMessagesOptions) => Promise<
|
|
33
|
+
getMessages: (options: GetMessagesOptions) => Promise<ChatMessageListResponse>;
|
|
47
34
|
}
|
|
48
35
|
|
|
49
36
|
// split contact status retrieval to avoid `414 Request-URI Too Large`.
|
|
@@ -68,9 +55,8 @@ export default ((client: ApiRequester, baseUrl: string): ChatD => ({
|
|
|
68
55
|
const uuids: Array<UUID> = contactUuids || [];
|
|
69
56
|
|
|
70
57
|
if (uuids.length > MAX_PRESENCE_FETCHED) {
|
|
71
|
-
const requests = uuids.reduce((acc, _, i) => {
|
|
58
|
+
const requests = uuids.reduce((acc: Promise<PresenceResponse[]>[], _, i) => {
|
|
72
59
|
if (i % MAX_PRESENCE_FETCHED === 0) {
|
|
73
|
-
// @ts-ignore
|
|
74
60
|
acc.push(this.getMultipleLineState(uuids.slice(i, i + MAX_PRESENCE_FETCHED)));
|
|
75
61
|
}
|
|
76
62
|
return acc;
|
|
@@ -97,5 +83,5 @@ export default ((client: ApiRequester, baseUrl: string): ChatD => ({
|
|
|
97
83
|
return client.get(`${baseUrl}/users/me/rooms/${roomUuid}/messages${qs.length ? `?${qs}` : ''}`).then((response: ChatMessageListResponse) => ChatMessage.parseMany(response));
|
|
98
84
|
},
|
|
99
85
|
sendRoomMessage: async (roomUuid: string, message: ChatMessage): Promise<ChatMessage> => client.post(`${baseUrl}/users/me/rooms/${roomUuid}/messages`, message).then(ChatMessage.parse),
|
|
100
|
-
getMessages: async (options: GetMessagesOptions): Promise<
|
|
86
|
+
getMessages: async (options: GetMessagesOptions): Promise<ChatMessageListResponse> => client.get(`${baseUrl}/users/me/rooms/messages`, options),
|
|
101
87
|
}));
|
package/src/api/dird.ts
CHANGED
|
@@ -1,27 +1,21 @@
|
|
|
1
1
|
import { jsonToGraphQLQuery } from 'json-to-graphql-query/lib/jsonToGraphQLQuery';
|
|
2
2
|
import ApiRequester from '../utils/api-requester';
|
|
3
|
-
import type { UUID } from '../domain/types';
|
|
4
|
-
import Contact from '../
|
|
5
|
-
import type { NewContact } from '../
|
|
6
|
-
import type { DirectorySource, DirectorySources } from '../domain/DirectorySource';
|
|
7
|
-
import type { Sources } from '../index';
|
|
8
|
-
import { ContactsResponse } from '../index';
|
|
3
|
+
import type { PhonebookResponseItem, UUID } from '../domain/types';
|
|
4
|
+
import { Contact, ContactsResponse } from '../index';
|
|
5
|
+
import type { NewContact, DirectorySource, DirectorySources } from '../index';
|
|
9
6
|
|
|
10
7
|
type PhoneBookSearchQueryParams = {
|
|
11
|
-
order
|
|
12
|
-
direction
|
|
13
|
-
limit
|
|
14
|
-
offset
|
|
8
|
+
order?: string;
|
|
9
|
+
direction?: 'asc' | 'desc';
|
|
10
|
+
limit?: number;
|
|
11
|
+
offset?: number;
|
|
15
12
|
};
|
|
16
13
|
|
|
17
14
|
const getContactPayload = (contact: NewContact | Contact) => ({
|
|
18
15
|
email: contact.email,
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
lastname: contact.lastName ? contact.lastName : '',
|
|
23
|
-
// @ts-ignore
|
|
24
|
-
number: contact.phoneNumber ? contact.phoneNumber : '',
|
|
16
|
+
firstname: (contact as any).firstName ? (contact as any).firstName : '',
|
|
17
|
+
lastname: (contact as any).lastName ? (contact as any).lastName : '',
|
|
18
|
+
number: (contact as any).phoneNumber ? (contact as any).phoneNumber : '',
|
|
25
19
|
entreprise: contact.entreprise ? contact.entreprise : '',
|
|
26
20
|
birthday: contact.birthday ? contact.birthday : '',
|
|
27
21
|
address: contact.address ? contact.address : '',
|
|
@@ -40,15 +34,15 @@ export interface DirD {
|
|
|
40
34
|
markAsFavorite: (source: string, sourceId: string) => Promise<boolean>;
|
|
41
35
|
removeFavorite: (source: string, sourceId: string) => Promise<void>;
|
|
42
36
|
fetchOffice365Source: (context: string) => Promise<DirectorySources>;
|
|
43
|
-
fetchOffice365Contacts: (source: DirectorySource, queryParams: ContactSearchQueryParams) => Promise<Contact[]>
|
|
44
|
-
fetchWazoSource: (context: string) => Promise<
|
|
45
|
-
fetchSourcesFor: (context: string, backend: string) => Promise<
|
|
46
|
-
fetchWazoContacts: (source: DirectorySource, queryParams: ContactSearchQueryParams) => Promise<Contact[]
|
|
47
|
-
fetchGoogleSource: (context: string) => Promise<
|
|
48
|
-
fetchGoogleContacts: (source: DirectorySource, queryParams: ContactSearchQueryParams) => Promise<Contact[]
|
|
49
|
-
fetchConferenceSource: (context: string) => Promise<
|
|
50
|
-
fetchConferenceContacts: (source: DirectorySource) => Promise<Contact[]
|
|
51
|
-
fetchPhonebookContacts: (source: DirectorySource) => Promise<
|
|
37
|
+
fetchOffice365Contacts: (source: DirectorySource, queryParams: ContactSearchQueryParams) => Promise<Contact[]> ;
|
|
38
|
+
fetchWazoSource: (context: string) => Promise<DirectorySources>;
|
|
39
|
+
fetchSourcesFor: (context: string, backend: string) => Promise<DirectorySources>;
|
|
40
|
+
fetchWazoContacts: (source: DirectorySource, queryParams: ContactSearchQueryParams) => Promise<Contact[]>;
|
|
41
|
+
fetchGoogleSource: (context: string) => Promise<DirectorySources>;
|
|
42
|
+
fetchGoogleContacts: (source: DirectorySource, queryParams: ContactSearchQueryParams) => Promise<Contact[]>;
|
|
43
|
+
fetchConferenceSource: (context: string) => Promise<DirectorySources>;
|
|
44
|
+
fetchConferenceContacts: (source: DirectorySource) => Promise<Contact[]>;
|
|
45
|
+
fetchPhonebookContacts: (source: DirectorySource, params?: PhoneBookSearchQueryParams) => Promise<{ items: PhonebookResponseItem[], total: number }>;
|
|
52
46
|
findMultipleContactsByNumber: (numbers: string[], fields?: Record<string, any>) => Promise<Contact[]>;
|
|
53
47
|
}
|
|
54
48
|
|
|
@@ -85,48 +79,48 @@ export default ((client: ApiRequester, baseUrl: string): DirD => ({
|
|
|
85
79
|
fetchOffice365Source: (context: string): Promise<DirectorySources> => client.get(`${baseUrl}/directories/${context}/sources`, {
|
|
86
80
|
backend: 'office365',
|
|
87
81
|
}),
|
|
88
|
-
fetchOffice365Contacts: (source: DirectorySource, queryParams: ContactSearchQueryParams = null): Promise<Contact[]>
|
|
82
|
+
fetchOffice365Contacts: (source: DirectorySource, queryParams: ContactSearchQueryParams = null): Promise<Contact[]> => {
|
|
89
83
|
if (!source) {
|
|
90
|
-
return
|
|
84
|
+
return Promise.resolve([]);
|
|
91
85
|
}
|
|
92
86
|
|
|
93
87
|
return client.get(`${baseUrl}/backends/office365/sources/${source.uuid}/contacts`, queryParams).then((response: any) => Contact.parseManyOffice365(response.items, source));
|
|
94
88
|
},
|
|
95
|
-
fetchWazoSource: (context: string): Promise<
|
|
89
|
+
fetchWazoSource: (context: string): Promise<DirectorySources> => client.get(`${baseUrl}/directories/${context}/sources`, {
|
|
96
90
|
backend: 'wazo',
|
|
97
91
|
}),
|
|
98
92
|
// Can be used with `queryParams = { uuid: uuid1, uuid2 }` to fetch multiple contacts
|
|
99
|
-
fetchWazoContacts: (source: DirectorySource, queryParams: ContactSearchQueryParams = null): Promise<Contact[]>
|
|
93
|
+
fetchWazoContacts: (source: DirectorySource, queryParams: ContactSearchQueryParams = null): Promise<Contact[]> => {
|
|
100
94
|
if (!source) {
|
|
101
|
-
return
|
|
95
|
+
return Promise.resolve([]);
|
|
102
96
|
}
|
|
103
97
|
|
|
104
98
|
return client.get(`${baseUrl}/backends/wazo/sources/${source.uuid}/contacts`, queryParams).then((response: any) => Contact.parseManyWazo(response.items, source));
|
|
105
99
|
},
|
|
106
|
-
fetchGoogleSource: (context: string): Promise<
|
|
100
|
+
fetchGoogleSource: (context: string): Promise<DirectorySources> => client.get(`${baseUrl}/directories/${context}/sources`, {
|
|
107
101
|
backend: 'google',
|
|
108
102
|
}),
|
|
109
|
-
fetchGoogleContacts: (source: DirectorySource, queryParams: ContactSearchQueryParams = null): Promise<Contact[]>
|
|
103
|
+
fetchGoogleContacts: (source: DirectorySource, queryParams: ContactSearchQueryParams = null): Promise<Contact[]> => {
|
|
110
104
|
if (!source) {
|
|
111
|
-
return
|
|
105
|
+
return Promise.resolve([]);
|
|
112
106
|
}
|
|
113
107
|
|
|
114
108
|
return client.get(`${baseUrl}/backends/google/sources/${source.uuid}/contacts`, queryParams).then((response: any) => Contact.parseManyGoogle(response.items, source));
|
|
115
109
|
},
|
|
116
|
-
fetchConferenceSource: (context: string): Promise<
|
|
110
|
+
fetchConferenceSource: (context: string): Promise<DirectorySources> => client.get(`${baseUrl}/directories/${context}/sources`, {
|
|
117
111
|
backend: 'conference',
|
|
118
112
|
}),
|
|
119
|
-
fetchSourcesFor: (context: string, backend: string): Promise<
|
|
120
|
-
fetchPhonebookContacts: (source: DirectorySource, params
|
|
113
|
+
fetchSourcesFor: (context: string, backend: string): Promise<DirectorySources> => client.get(`${baseUrl}/directories/${context}/sources`, { backend }),
|
|
114
|
+
fetchPhonebookContacts: (source: DirectorySource, params?: PhoneBookSearchQueryParams): Promise<{ items: PhonebookResponseItem[], total: number }> => {
|
|
121
115
|
if (!source) {
|
|
122
|
-
return
|
|
116
|
+
return Promise.resolve({ items: [], total: 0 });
|
|
123
117
|
}
|
|
124
118
|
|
|
125
119
|
return client.get(`${baseUrl}/backends/phonebook/sources/${source.uuid}/contacts`, params);
|
|
126
120
|
},
|
|
127
|
-
fetchConferenceContacts: (source: DirectorySource): Promise<Contact[]>
|
|
121
|
+
fetchConferenceContacts: (source: DirectorySource): Promise<Contact[]> => {
|
|
128
122
|
if (!source) {
|
|
129
|
-
return
|
|
123
|
+
return Promise.resolve([]);
|
|
130
124
|
}
|
|
131
125
|
|
|
132
126
|
return client.get(`${baseUrl}/backends/conference/sources/${source.uuid}/contacts`).then((response: any) => Contact.parseManyConference(response.items, source));
|
|
@@ -21,11 +21,11 @@ export default {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
const mobile = isMobile();
|
|
24
|
-
const offerOptions
|
|
24
|
+
const offerOptions = {
|
|
25
25
|
offerToReceiveAudio: 1,
|
|
26
26
|
};
|
|
27
27
|
const ips: string[] = [];
|
|
28
|
-
const config:
|
|
28
|
+
const config: RTCConfiguration = {
|
|
29
29
|
iceServers: [{
|
|
30
30
|
urls: 'stun:stun1.l.google.com:19302',
|
|
31
31
|
}, {
|
|
@@ -43,7 +43,7 @@ export default {
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
if (externalAppConfig && externalAppConfig.turn_servers) {
|
|
46
|
-
config.iceServers = [...JSON.parse(externalAppConfig.turn_servers), ...config.iceServers];
|
|
46
|
+
config.iceServers = [...JSON.parse(externalAppConfig.turn_servers), ...(config.iceServers || [])];
|
|
47
47
|
// Force to use TURN when defined in config
|
|
48
48
|
config.iceTransportPolicy = 'relay';
|
|
49
49
|
}
|
|
@@ -66,8 +66,7 @@ export default {
|
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
if (ips.every(checkIsIPV4)) {
|
|
69
|
-
|
|
70
|
-
resolve();
|
|
69
|
+
resolve(null);
|
|
71
70
|
} else {
|
|
72
71
|
const nonIPV4 = ips.find(ip => !checkIsIPV4(ip));
|
|
73
72
|
reject(new Error(`Non IPv4 ice candidate found : ${nonIPV4}.`));
|
|
@@ -10,8 +10,8 @@ export default {
|
|
|
10
10
|
return resolve('Skipped on node');
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
const candidates: any = {};
|
|
14
|
-
const rawCandidates: any = [];
|
|
13
|
+
const candidates: Record<string, any> = {};
|
|
14
|
+
const rawCandidates: any[] = [];
|
|
15
15
|
let nbCandidates = 0;
|
|
16
16
|
const pc = new RTCPeerConnection({
|
|
17
17
|
iceServers: [{
|
|
@@ -22,7 +22,7 @@ export default {
|
|
|
22
22
|
urls: 'stun:stun2.l.google.com:19302',
|
|
23
23
|
}],
|
|
24
24
|
});
|
|
25
|
-
let timeout:
|
|
25
|
+
let timeout: string | number | NodeJS.Timeout | undefined;
|
|
26
26
|
|
|
27
27
|
const onEnded = () => {
|
|
28
28
|
clearTimeout(timeout);
|
|
@@ -44,7 +44,7 @@ export default {
|
|
|
44
44
|
timeout = setTimeout(onEnded, timeoutDuration);
|
|
45
45
|
pc.createDataChannel('wazo-check-nat');
|
|
46
46
|
|
|
47
|
-
pc.onicecandidate = e => {
|
|
47
|
+
pc.onicecandidate = (e: RTCPeerConnectionIceEvent) => {
|
|
48
48
|
nbCandidates++;
|
|
49
49
|
|
|
50
50
|
if (e.candidate) {
|
|
@@ -52,9 +52,13 @@ export default {
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
if (e.candidate && e.candidate.candidate.indexOf('srflx') !== -1) {
|
|
55
|
-
const cand
|
|
56
|
-
if (
|
|
57
|
-
|
|
55
|
+
const cand = parseCandidate(e.candidate.candidate);
|
|
56
|
+
if (cand.relatedPort) {
|
|
57
|
+
if (!candidates[cand.relatedPort]) {
|
|
58
|
+
candidates[cand.relatedPort] = [];
|
|
59
|
+
}
|
|
60
|
+
candidates[cand.relatedPort].push(cand.port);
|
|
61
|
+
}
|
|
58
62
|
} else if (!e.candidate) {
|
|
59
63
|
onEnded();
|
|
60
64
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Invitation, Inviter } from 'sip.js';
|
|
2
1
|
import WebRTCClient from '../../web-rtc-client';
|
|
2
|
+
import { WazoSession } from '../../domain/types';
|
|
3
3
|
|
|
4
4
|
export default {
|
|
5
5
|
name: 'WebRTC Transport (WS) ~30s',
|
|
6
|
-
check: (server: string, session:
|
|
6
|
+
check: (server: string, session: WazoSession): Promise<void> => new Promise((resolve, reject) => {
|
|
7
7
|
const [host, port = 443] = server.split(':');
|
|
8
8
|
|
|
9
9
|
const client = new WebRTCClient({
|
|
@@ -76,7 +76,7 @@ export default class AdHocAPIConference {
|
|
|
76
76
|
|
|
77
77
|
async start() {
|
|
78
78
|
this.started = true;
|
|
79
|
-
// @ts-ignore
|
|
79
|
+
// @ts-ignore: date / number
|
|
80
80
|
this.answerTime = Object.values(this.participants).length ? Object.values(this.participants)[0].answerTime : null;
|
|
81
81
|
const participantIds = Object.keys(this.participants);
|
|
82
82
|
const conference = await getApiClient().calld.createAdHocConference(this.host.callId, participantIds);
|