@wazo/sdk 0.39.6 → 0.39.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/wazo-sdk.js +3 -3
- package/esm/__tests__/api-client.test.js +4 -6
- package/esm/domain/Session.js +8 -4
- package/esm/domain/__tests__/Session.test.js +1 -0
- package/esm/types/domain/Session.d.ts +4 -2
- package/esm/types/domain/Session.d.ts.map +1 -1
- package/esm/types/utils/api-requester.d.ts.map +1 -1
- package/esm/types/web-rtc-client.d.ts +2 -2
- package/esm/types/web-rtc-client.d.ts.map +1 -1
- package/esm/utils/__tests__/api-requester.test.js +3 -5
- package/esm/utils/api-requester.js +3 -4
- package/esm/web-rtc-client.js +13 -9
- package/lib/__tests__/api-client.test.js +4 -6
- package/lib/domain/Session.js +7 -3
- package/lib/domain/__tests__/Session.test.js +1 -0
- package/lib/types/domain/Session.d.ts +4 -2
- package/lib/types/domain/Session.d.ts.map +1 -1
- package/lib/types/utils/api-requester.d.ts.map +1 -1
- package/lib/types/web-rtc-client.d.ts +2 -2
- package/lib/types/web-rtc-client.d.ts.map +1 -1
- package/lib/utils/__tests__/api-requester.test.js +3 -5
- package/lib/utils/api-requester.js +1 -1
- package/lib/web-rtc-client.js +13 -9
- package/package.json +1 -1
- package/src/__tests__/api-client.test.ts +4 -7
- package/src/domain/Session.ts +11 -4
- package/src/domain/__tests__/Session.test.ts +1 -0
- package/src/utils/__tests__/api-requester.test.ts +3 -6
- package/src/utils/api-requester.ts +3 -4
- package/src/web-rtc-client.ts +13 -9
|
@@ -12,7 +12,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const node_abort_controller_1 = require("node-abort-controller");
|
|
16
15
|
const api_requester_1 = __importDefault(require("../api-requester"));
|
|
17
16
|
const server = 'localhost';
|
|
18
17
|
const path = 'auth';
|
|
@@ -28,7 +27,6 @@ const headers = {
|
|
|
28
27
|
'Content-Type': 'application/json',
|
|
29
28
|
'X-Auth-Token': token,
|
|
30
29
|
};
|
|
31
|
-
const controller = new node_abort_controller_1.AbortController();
|
|
32
30
|
describe('Generating query string', () => {
|
|
33
31
|
it('should generate a simple query string from an object', () => {
|
|
34
32
|
expect(api_requester_1.default.getQueryString({
|
|
@@ -108,7 +106,7 @@ describe('Calling fetch', () => {
|
|
|
108
106
|
expect(global.fetch).toBeCalledWith(url, {
|
|
109
107
|
method: 'get',
|
|
110
108
|
body: null,
|
|
111
|
-
signal:
|
|
109
|
+
signal: expect.any(Object),
|
|
112
110
|
headers: {},
|
|
113
111
|
agent: null,
|
|
114
112
|
});
|
|
@@ -150,14 +148,14 @@ describe('With a refresh token', () => {
|
|
|
150
148
|
expect(global.fetch).toHaveBeenNthCalledWith(1, url, {
|
|
151
149
|
method: 'get',
|
|
152
150
|
body: null,
|
|
153
|
-
signal:
|
|
151
|
+
signal: expect.any(Object),
|
|
154
152
|
headers,
|
|
155
153
|
agent: null,
|
|
156
154
|
});
|
|
157
155
|
expect(global.fetch).toHaveBeenNthCalledWith(2, url, {
|
|
158
156
|
method: 'get',
|
|
159
157
|
body: null,
|
|
160
|
-
signal:
|
|
158
|
+
signal: expect.any(Object),
|
|
161
159
|
headers: updatedHeaders,
|
|
162
160
|
agent: null,
|
|
163
161
|
});
|
|
@@ -117,7 +117,7 @@ class ApiRequester {
|
|
|
117
117
|
const hasEmptyResponse = method === 'delete' || isHead;
|
|
118
118
|
const newParse = hasEmptyResponse ? ApiRequester.successResponseParser : parse;
|
|
119
119
|
const fetchOptions = Object.assign({}, (this.fetchOptions || {}));
|
|
120
|
-
const controller = new node_abort_controller_1.AbortController();
|
|
120
|
+
const controller = typeof AbortController !== 'undefined' ? new AbortController() : new node_abort_controller_1.AbortController();
|
|
121
121
|
const extraHeaders = fetchOptions.headers || {};
|
|
122
122
|
delete fetchOptions.headers;
|
|
123
123
|
const options = Object.assign({ method, body: newBody, signal: controller ? controller.signal : null, headers: Object.assign(Object.assign({}, this.getHeaders(headers)), extraHeaders), agent: this.agent }, fetchOptions);
|
package/lib/web-rtc-client.js
CHANGED
|
@@ -1251,12 +1251,12 @@ class WebRTCClient extends Emitter_1.default {
|
|
|
1251
1251
|
wasMuted,
|
|
1252
1252
|
shouldDoScreenSharing,
|
|
1253
1253
|
});
|
|
1254
|
-
this.updateRemoteStream(this.getSipSessionId(sipSession));
|
|
1254
|
+
this.updateRemoteStream(this.getSipSessionId(sipSession), false);
|
|
1255
1255
|
if (wasMuted) {
|
|
1256
1256
|
this.mute(sipSession);
|
|
1257
1257
|
}
|
|
1258
1258
|
// @ts-ignore
|
|
1259
|
-
this._onAccepted(sipSession, response.session, false);
|
|
1259
|
+
this._onAccepted(sipSession, response.session, false, false);
|
|
1260
1260
|
if (shouldDoScreenSharing) {
|
|
1261
1261
|
this.eventEmitter.emit(ON_SCREEN_SHARING_REINVITE, sipSession, response, desktop);
|
|
1262
1262
|
}
|
|
@@ -1475,7 +1475,7 @@ class WebRTCClient extends Emitter_1.default {
|
|
|
1475
1475
|
// Update the local video element
|
|
1476
1476
|
this._setupMedias(sipSession, newStream);
|
|
1477
1477
|
}
|
|
1478
|
-
updateRemoteStream(sessionId) {
|
|
1478
|
+
updateRemoteStream(sessionId, allTracks = true) {
|
|
1479
1479
|
const remoteStream = this.getRemoteStream(sessionId);
|
|
1480
1480
|
const pc = this.getPeerConnection(sessionId);
|
|
1481
1481
|
logger.info('Updating remote stream', {
|
|
@@ -1486,12 +1486,16 @@ class WebRTCClient extends Emitter_1.default {
|
|
|
1486
1486
|
if (!pc || !remoteStream) {
|
|
1487
1487
|
return;
|
|
1488
1488
|
}
|
|
1489
|
-
remoteStream.
|
|
1490
|
-
|
|
1489
|
+
remoteStream.getTracks().forEach(track => {
|
|
1490
|
+
if (allTracks || track.kind === 'video') {
|
|
1491
|
+
remoteStream.removeTrack(track);
|
|
1492
|
+
}
|
|
1491
1493
|
});
|
|
1492
1494
|
if (pc.getReceivers) {
|
|
1493
1495
|
pc.getReceivers().forEach((receiver) => {
|
|
1494
|
-
|
|
1496
|
+
if (allTracks || receiver.track.kind === 'video') {
|
|
1497
|
+
remoteStream.addTrack(receiver.track);
|
|
1498
|
+
}
|
|
1495
1499
|
});
|
|
1496
1500
|
}
|
|
1497
1501
|
}
|
|
@@ -1788,7 +1792,7 @@ class WebRTCClient extends Emitter_1.default {
|
|
|
1788
1792
|
// @ts-ignore
|
|
1789
1793
|
session.outgoingInviteRequest.message.body.body = request.body;
|
|
1790
1794
|
}
|
|
1791
|
-
this.updateRemoteStream(sipSessionId);
|
|
1795
|
+
this.updateRemoteStream(sipSessionId, false);
|
|
1792
1796
|
this._setupMedias(session);
|
|
1793
1797
|
return this.eventEmitter.emit(ON_REINVITE, session, request, updatedCalleeName, updatedNumber, hadRemoteVideo);
|
|
1794
1798
|
};
|
|
@@ -1802,7 +1806,7 @@ class WebRTCClient extends Emitter_1.default {
|
|
|
1802
1806
|
});
|
|
1803
1807
|
this.eventEmitter.emit(ON_EARLY_MEDIA, session);
|
|
1804
1808
|
}
|
|
1805
|
-
_onAccepted(session, sessionDialog, withEvent = true) {
|
|
1809
|
+
_onAccepted(session, sessionDialog, withEvent = true, initAllTracks = true) {
|
|
1806
1810
|
var _a;
|
|
1807
1811
|
logger.info('on call accepted', {
|
|
1808
1812
|
id: session.id,
|
|
@@ -1812,7 +1816,7 @@ class WebRTCClient extends Emitter_1.default {
|
|
|
1812
1816
|
});
|
|
1813
1817
|
this.storeSipSession(session);
|
|
1814
1818
|
this._setupMedias(session);
|
|
1815
|
-
this.updateRemoteStream(this.getSipSessionId(session));
|
|
1819
|
+
this.updateRemoteStream(this.getSipSessionId(session), initAllTracks);
|
|
1816
1820
|
// @ts-ignore
|
|
1817
1821
|
const pc = (_a = session.sessionDescriptionHandler) === null || _a === void 0 ? void 0 : _a.peerConnection;
|
|
1818
1822
|
const onTrack = (event) => {
|
package/package.json
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { AbortController } from 'node-abort-controller';
|
|
2
1
|
import { Base64 } from 'js-base64';
|
|
3
2
|
|
|
4
3
|
import WazoApiClient from '../api-client';
|
|
@@ -6,8 +5,6 @@ import ServerError from '../domain/ServerError';
|
|
|
6
5
|
import BadResponse from '../domain/BadResponse';
|
|
7
6
|
import Session from '../domain/Session';
|
|
8
7
|
|
|
9
|
-
const controller = new AbortController();
|
|
10
|
-
|
|
11
8
|
const mockedResponse = {
|
|
12
9
|
data: {
|
|
13
10
|
token: 1,
|
|
@@ -116,7 +113,7 @@ describe('With correct API results', () => {
|
|
|
116
113
|
expect(global.fetch).toBeCalledWith(`https://${server}/api/auth/${authVersion}/token`, {
|
|
117
114
|
method: 'post',
|
|
118
115
|
body: JSON.stringify(data),
|
|
119
|
-
signal:
|
|
116
|
+
signal: expect.any(Object),
|
|
120
117
|
headers,
|
|
121
118
|
agent: null,
|
|
122
119
|
});
|
|
@@ -131,7 +128,7 @@ describe('With correct API results', () => {
|
|
|
131
128
|
expect(global.fetch).toBeCalledWith(`https://${server}/api/auth/${authVersion}/token/${oldToken}`, {
|
|
132
129
|
method: 'delete',
|
|
133
130
|
body: null,
|
|
134
|
-
signal:
|
|
131
|
+
signal: expect.any(Object),
|
|
135
132
|
headers: {},
|
|
136
133
|
agent: null,
|
|
137
134
|
});
|
|
@@ -154,7 +151,7 @@ describe('With unAuthorized API results', () => {
|
|
|
154
151
|
expect(global.fetch).toBeCalledWith(`https://${server}/api/auth/${authVersion}/token/${tokenToCheck}`, {
|
|
155
152
|
method: 'head',
|
|
156
153
|
body: null,
|
|
157
|
-
signal:
|
|
154
|
+
signal: expect.any(Object),
|
|
158
155
|
headers: {},
|
|
159
156
|
agent: null,
|
|
160
157
|
});
|
|
@@ -186,7 +183,7 @@ describe('With not found API results', () => {
|
|
|
186
183
|
expect(global.fetch).toBeCalledWith(`https://${server}/api/calld/1.0/users/me/voicemails`, {
|
|
187
184
|
method: 'get',
|
|
188
185
|
body: null,
|
|
189
|
-
signal:
|
|
186
|
+
signal: expect.any(Object),
|
|
190
187
|
headers: {
|
|
191
188
|
'X-Auth-Token': token,
|
|
192
189
|
'Content-Type': 'application/json',
|
package/src/domain/Session.ts
CHANGED
|
@@ -66,7 +66,9 @@ type SessionArguments = {
|
|
|
66
66
|
expiresAt: Date;
|
|
67
67
|
authorizations?: Array<Authorization>;
|
|
68
68
|
engineVersion?: string | null | undefined;
|
|
69
|
+
// Deprecated, use `stackUuid`
|
|
69
70
|
engineUuid?: string | null | undefined;
|
|
71
|
+
stackUuid?: string | null | undefined;
|
|
70
72
|
};
|
|
71
73
|
|
|
72
74
|
export default class Session {
|
|
@@ -82,7 +84,7 @@ export default class Session {
|
|
|
82
84
|
|
|
83
85
|
tenantUuid: string | null | undefined;
|
|
84
86
|
|
|
85
|
-
|
|
87
|
+
stackUuid: string | null | undefined;
|
|
86
88
|
|
|
87
89
|
sessionUuid: string | null | undefined;
|
|
88
90
|
|
|
@@ -121,7 +123,7 @@ export default class Session {
|
|
|
121
123
|
acl: plain.data.acls ? plain.data.acls : plain.data.acl ? plain.data.acl : [],
|
|
122
124
|
tenantUuid: plain.data.metadata ? plain.data.metadata.tenant_uuid : undefined,
|
|
123
125
|
expiresAt: new Date(`${plain.data.utc_expires_at}z`),
|
|
124
|
-
|
|
126
|
+
stackUuid: plain.data.xivo_uuid,
|
|
125
127
|
});
|
|
126
128
|
}
|
|
127
129
|
|
|
@@ -140,7 +142,7 @@ export default class Session {
|
|
|
140
142
|
engineVersion,
|
|
141
143
|
refreshToken,
|
|
142
144
|
sessionUuid,
|
|
143
|
-
|
|
145
|
+
stackUuid,
|
|
144
146
|
}: SessionArguments) {
|
|
145
147
|
this.token = token;
|
|
146
148
|
this.uuid = uuid;
|
|
@@ -152,7 +154,7 @@ export default class Session {
|
|
|
152
154
|
this.engineVersion = engineVersion;
|
|
153
155
|
this.refreshToken = refreshToken;
|
|
154
156
|
this.sessionUuid = sessionUuid;
|
|
155
|
-
this.
|
|
157
|
+
this.stackUuid = stackUuid;
|
|
156
158
|
}
|
|
157
159
|
|
|
158
160
|
hasExpired(date: Date = new Date()): boolean {
|
|
@@ -269,4 +271,9 @@ export default class Session {
|
|
|
269
271
|
return this.acl;
|
|
270
272
|
}
|
|
271
273
|
|
|
274
|
+
get engineUuid(): string | null | undefined {
|
|
275
|
+
console.warn('`engineUuid` property of Session has been removed in Wazo\'s SDK, please use `stackUuid` instead.');
|
|
276
|
+
return this.stackUuid;
|
|
277
|
+
}
|
|
278
|
+
|
|
272
279
|
}
|
|
@@ -30,6 +30,7 @@ describe('Session domain', () => {
|
|
|
30
30
|
expiresAt: new Date('2017-07-19T21:27:53.086990z'),
|
|
31
31
|
sessionUuid: 'f14dd6d6-547c-434d-bd5c-e882b5b83b32',
|
|
32
32
|
engineUuid: '6cd695d2-cdb9-4444-8b2d-27425ab85fa8',
|
|
33
|
+
stackUuid: '6cd695d2-cdb9-4444-8b2d-27425ab85fa8',
|
|
33
34
|
}));
|
|
34
35
|
});
|
|
35
36
|
describe('about voicemails', () => {
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { AbortController } from 'node-abort-controller';
|
|
2
|
-
|
|
3
1
|
import ApiRequester from '../api-requester';
|
|
4
2
|
|
|
5
3
|
const server = 'localhost';
|
|
@@ -16,7 +14,6 @@ const headers = {
|
|
|
16
14
|
'Content-Type': 'application/json',
|
|
17
15
|
'X-Auth-Token': token,
|
|
18
16
|
};
|
|
19
|
-
const controller = new AbortController();
|
|
20
17
|
|
|
21
18
|
describe('Generating query string', () => {
|
|
22
19
|
it('should generate a simple query string from an object', () => {
|
|
@@ -103,7 +100,7 @@ describe('Calling fetch', () => {
|
|
|
103
100
|
expect(global.fetch).toBeCalledWith(url, {
|
|
104
101
|
method: 'get',
|
|
105
102
|
body: null,
|
|
106
|
-
signal:
|
|
103
|
+
signal: expect.any(Object),
|
|
107
104
|
headers: {},
|
|
108
105
|
agent: null,
|
|
109
106
|
});
|
|
@@ -148,14 +145,14 @@ describe('With a refresh token', () => {
|
|
|
148
145
|
expect(global.fetch).toHaveBeenNthCalledWith(1, url, {
|
|
149
146
|
method: 'get',
|
|
150
147
|
body: null,
|
|
151
|
-
signal:
|
|
148
|
+
signal: expect.any(Object),
|
|
152
149
|
headers,
|
|
153
150
|
agent: null,
|
|
154
151
|
});
|
|
155
152
|
expect(global.fetch).toHaveBeenNthCalledWith(2, url, {
|
|
156
153
|
method: 'get',
|
|
157
154
|
body: null,
|
|
158
|
-
signal:
|
|
155
|
+
signal: expect.any(Object),
|
|
159
156
|
headers: updatedHeaders,
|
|
160
157
|
agent: null,
|
|
161
158
|
});
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
/* eslint-disable import/no-dynamic-require */
|
|
7
7
|
import { Base64 } from 'js-base64';
|
|
8
|
-
import { AbortController } from 'node-abort-controller';
|
|
8
|
+
import { AbortController as NodeAbortController } from 'node-abort-controller';
|
|
9
9
|
|
|
10
10
|
import BadResponse from '../domain/BadResponse';
|
|
11
11
|
import ServerError from '../domain/ServerError';
|
|
@@ -171,9 +171,8 @@ export default class ApiRequester {
|
|
|
171
171
|
const isHead = method === 'head';
|
|
172
172
|
const hasEmptyResponse = method === 'delete' || isHead;
|
|
173
173
|
const newParse = hasEmptyResponse ? ApiRequester.successResponseParser : parse;
|
|
174
|
-
const fetchOptions = { ...(this.fetchOptions || {})
|
|
175
|
-
|
|
176
|
-
const controller = new AbortController();
|
|
174
|
+
const fetchOptions = { ...(this.fetchOptions || {}) };
|
|
175
|
+
const controller = typeof AbortController !== 'undefined' ? new AbortController() : new NodeAbortController();
|
|
177
176
|
const extraHeaders = fetchOptions.headers || {};
|
|
178
177
|
delete fetchOptions.headers;
|
|
179
178
|
const options = {
|
package/src/web-rtc-client.ts
CHANGED
|
@@ -1493,14 +1493,14 @@ export default class WebRTCClient extends Emitter {
|
|
|
1493
1493
|
wasMuted,
|
|
1494
1494
|
shouldDoScreenSharing,
|
|
1495
1495
|
});
|
|
1496
|
-
this.updateRemoteStream(this.getSipSessionId(sipSession));
|
|
1496
|
+
this.updateRemoteStream(this.getSipSessionId(sipSession), false);
|
|
1497
1497
|
|
|
1498
1498
|
if (wasMuted) {
|
|
1499
1499
|
this.mute(sipSession);
|
|
1500
1500
|
}
|
|
1501
1501
|
|
|
1502
1502
|
// @ts-ignore
|
|
1503
|
-
this._onAccepted(sipSession, response.session, false);
|
|
1503
|
+
this._onAccepted(sipSession, response.session, false, false);
|
|
1504
1504
|
|
|
1505
1505
|
if (shouldDoScreenSharing) {
|
|
1506
1506
|
this.eventEmitter.emit(ON_SCREEN_SHARING_REINVITE, sipSession, response, desktop);
|
|
@@ -1775,7 +1775,7 @@ export default class WebRTCClient extends Emitter {
|
|
|
1775
1775
|
this._setupMedias(sipSession, newStream);
|
|
1776
1776
|
}
|
|
1777
1777
|
|
|
1778
|
-
updateRemoteStream(sessionId: string): void {
|
|
1778
|
+
updateRemoteStream(sessionId: string, allTracks = true): void {
|
|
1779
1779
|
const remoteStream = this.getRemoteStream(sessionId);
|
|
1780
1780
|
const pc = this.getPeerConnection(sessionId);
|
|
1781
1781
|
logger.info('Updating remote stream', {
|
|
@@ -1788,13 +1788,17 @@ export default class WebRTCClient extends Emitter {
|
|
|
1788
1788
|
return;
|
|
1789
1789
|
}
|
|
1790
1790
|
|
|
1791
|
-
remoteStream.
|
|
1792
|
-
|
|
1791
|
+
remoteStream.getTracks().forEach(track => {
|
|
1792
|
+
if (allTracks || track.kind === 'video') {
|
|
1793
|
+
remoteStream.removeTrack(track);
|
|
1794
|
+
}
|
|
1793
1795
|
});
|
|
1794
1796
|
|
|
1795
1797
|
if (pc.getReceivers) {
|
|
1796
1798
|
pc.getReceivers().forEach((receiver: any) => {
|
|
1797
|
-
|
|
1799
|
+
if (allTracks || receiver.track.kind === 'video') {
|
|
1800
|
+
remoteStream.addTrack(receiver.track);
|
|
1801
|
+
}
|
|
1798
1802
|
});
|
|
1799
1803
|
}
|
|
1800
1804
|
}
|
|
@@ -2164,7 +2168,7 @@ export default class WebRTCClient extends Emitter {
|
|
|
2164
2168
|
session.outgoingInviteRequest.message.body.body = request.body;
|
|
2165
2169
|
}
|
|
2166
2170
|
|
|
2167
|
-
this.updateRemoteStream(sipSessionId);
|
|
2171
|
+
this.updateRemoteStream(sipSessionId, false);
|
|
2168
2172
|
|
|
2169
2173
|
this._setupMedias(session);
|
|
2170
2174
|
|
|
@@ -2183,7 +2187,7 @@ export default class WebRTCClient extends Emitter {
|
|
|
2183
2187
|
this.eventEmitter.emit(ON_EARLY_MEDIA, session);
|
|
2184
2188
|
}
|
|
2185
2189
|
|
|
2186
|
-
_onAccepted(session: Inviter | Invitation, sessionDialog?: SessionDialog, withEvent = true): void {
|
|
2190
|
+
_onAccepted(session: Inviter | Invitation, sessionDialog?: SessionDialog, withEvent = true, initAllTracks = true): void {
|
|
2187
2191
|
logger.info('on call accepted', {
|
|
2188
2192
|
id: session.id,
|
|
2189
2193
|
clientId: this.clientId,
|
|
@@ -2194,7 +2198,7 @@ export default class WebRTCClient extends Emitter {
|
|
|
2194
2198
|
|
|
2195
2199
|
this._setupMedias(session);
|
|
2196
2200
|
|
|
2197
|
-
this.updateRemoteStream(this.getSipSessionId(session));
|
|
2201
|
+
this.updateRemoteStream(this.getSipSessionId(session), initAllTracks);
|
|
2198
2202
|
// @ts-ignore
|
|
2199
2203
|
const pc = session.sessionDescriptionHandler?.peerConnection;
|
|
2200
2204
|
|