@wazo/sdk 0.41.1 → 0.41.2
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 +42 -41913
- package/esm/__tests__/api-client.test.js +15 -5
- package/esm/service/__tests__/IssueReporter.test.js +5 -1
- package/esm/types/service/getApiClient.d.ts.map +1 -1
- package/esm/types/utils/array.d.ts.map +1 -1
- package/esm/utils/__tests__/api-requester.test.js +19 -15
- package/esm/web-rtc-client.js +1 -1
- package/esm/websocket-client.js +1 -1
- package/lib/__tests__/api-client.test.js +15 -5
- package/lib/checker/Checker.js +2 -2
- package/lib/domain/Phone/WebRTCPhone.js +12 -12
- package/lib/service/CallApi.js +4 -4
- package/lib/service/__tests__/IssueReporter.test.js +5 -1
- package/lib/simple/Auth.js +5 -5
- package/lib/simple/Phone.js +9 -9
- package/lib/simple/room/Participant.js +2 -2
- package/lib/simple/room/Room.js +8 -8
- package/lib/simple/room/SipRoom.js +2 -2
- package/lib/simple/utils.js +1 -1
- package/lib/types/service/getApiClient.d.ts.map +1 -1
- package/lib/types/utils/array.d.ts.map +1 -1
- package/lib/utils/__tests__/api-requester.test.js +19 -15
- package/lib/utils/api-requester.js +2 -2
- package/lib/web-rtc-client.js +23 -27
- package/lib/websocket-client.js +1 -1
- package/package.json +23 -20
- package/src/__tests__/api-client.test.ts +15 -5
- package/src/service/__tests__/IssueReporter.test.ts +5 -1
- package/src/utils/__tests__/api-requester.test.ts +20 -16
- package/src/web-rtc-client.ts +1 -1
- package/src/websocket-client.ts +1 -1
|
@@ -73,7 +73,9 @@ client.setToken(token);
|
|
|
73
73
|
describe('With correct API results', () => {
|
|
74
74
|
beforeEach(() => {
|
|
75
75
|
jest.resetModules();
|
|
76
|
-
|
|
76
|
+
Object.defineProperty(global, 'fetch', {
|
|
77
|
+
value: jest.fn(() => Promise.resolve(mockedJson)),
|
|
78
|
+
});
|
|
77
79
|
});
|
|
78
80
|
describe('logIn test', () => {
|
|
79
81
|
it('should retrieve user token', async () => {
|
|
@@ -117,7 +119,9 @@ describe('With correct API results', () => {
|
|
|
117
119
|
describe('With unAuthorized API results', () => {
|
|
118
120
|
beforeEach(() => {
|
|
119
121
|
jest.resetModules();
|
|
120
|
-
|
|
122
|
+
Object.defineProperty(global, 'fetch', {
|
|
123
|
+
value: jest.fn(() => Promise.resolve(mockedUnAuthorized)),
|
|
124
|
+
});
|
|
121
125
|
});
|
|
122
126
|
describe('checkLogin test', () => {
|
|
123
127
|
it('should return false on 401 status', async () => {
|
|
@@ -137,7 +141,9 @@ describe('With unAuthorized API results', () => {
|
|
|
137
141
|
describe('With not found API results', () => {
|
|
138
142
|
beforeEach(() => {
|
|
139
143
|
jest.resetModules();
|
|
140
|
-
|
|
144
|
+
Object.defineProperty(global, 'fetch', {
|
|
145
|
+
value: jest.fn(() => Promise.resolve(mockedNotFound)),
|
|
146
|
+
});
|
|
141
147
|
});
|
|
142
148
|
describe('fetchVoicemail test', () => {
|
|
143
149
|
it('should throw a BadResponse instance on 404 status', async () => {
|
|
@@ -169,7 +175,9 @@ describe('With not found API results', () => {
|
|
|
169
175
|
describe('With erroneous text API results', () => {
|
|
170
176
|
beforeEach(() => {
|
|
171
177
|
jest.resetModules();
|
|
172
|
-
|
|
178
|
+
Object.defineProperty(global, 'fetch', {
|
|
179
|
+
value: jest.fn(() => Promise.resolve(mockedTextError)),
|
|
180
|
+
});
|
|
173
181
|
});
|
|
174
182
|
it('throw an exception when the response is >= 500', async () => {
|
|
175
183
|
let error = null;
|
|
@@ -191,7 +199,9 @@ describe('With erroneous text API results', () => {
|
|
|
191
199
|
describe('With erroneous json API results', () => {
|
|
192
200
|
beforeEach(() => {
|
|
193
201
|
jest.resetModules();
|
|
194
|
-
|
|
202
|
+
Object.defineProperty(global, 'fetch', {
|
|
203
|
+
value: jest.fn(() => Promise.resolve(mockedJsonError)),
|
|
204
|
+
});
|
|
195
205
|
});
|
|
196
206
|
it('throw an exception when the response is >= 500', async () => {
|
|
197
207
|
let error = null;
|
|
@@ -17,7 +17,11 @@ describe('IssueReporter', () => {
|
|
|
17
17
|
});
|
|
18
18
|
beforeEach(() => {
|
|
19
19
|
jest.resetAllMocks();
|
|
20
|
-
|
|
20
|
+
Object.defineProperty(global, 'fetch', {
|
|
21
|
+
value: jest.fn(() => ({
|
|
22
|
+
catch: () => { },
|
|
23
|
+
})),
|
|
24
|
+
});
|
|
21
25
|
});
|
|
22
26
|
afterAll(() => {
|
|
23
27
|
console.log = oldLog;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getApiClient.d.ts","sourceRoot":"","sources":["../../../src/service/getApiClient.ts"],"names":[],"mappings":"AACA,OAAO,aAAa,MAAM,eAAe,CAAC;AAkB1C,eAAO,MAAM,cAAc,aAAc,MAAM,cAAa,MAAM,GAAG,IAAI,GAAG,SAAS,SAEpF,CAAC;AACF,eAAO,MAAM,gBAAgB,cAAe,MAAM,SAEjD,CAAC;AACF,eAAO,MAAM,WAAW,aAAc,MAAM,GAAG,IAAI,GAAG,SAAS,cAAa,MAAM,GAAG,IAAI,GAAG,SAAS,SAEpG,CAAC;AACF,eAAO,MAAM,eAAe,oBAAqB,MAAM,GAAG,IAAI,GAAG,SAAS,cAAa,MAAM,GAAG,IAAI,GAAG,SAAS,SAE/G,CAAC;AACF,eAAO,MAAM,kBAAkB,oBAAqB,MAAM,GAAG,IAAI,GAAG,SAAS,cAAa,MAAM,GAAG,IAAI,GAAG,SAAS,SAGlH,CAAC;AACF,eAAO,MAAM,oBAAoB,sBAAuB,MAAM,GAAG,IAAI,GAAG,SAAS,cAAa,MAAM,GAAG,IAAI,GAAG,SAAS,SAEtH,CAAC;AACF,eAAO,MAAM,iBAAiB,
|
|
1
|
+
{"version":3,"file":"getApiClient.d.ts","sourceRoot":"","sources":["../../../src/service/getApiClient.ts"],"names":[],"mappings":"AACA,OAAO,aAAa,MAAM,eAAe,CAAC;AAkB1C,eAAO,MAAM,cAAc,aAAc,MAAM,cAA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AM,GAAG,IAAI,GAAG,SAAS,SAEtG,CAAC;AACF,eAAO,MAAM,eAAe,eAAe,MAAM,GAAG,IAAI,GAAG,SAAS,QAC6C,CAAC;qCAkCtF,MAAM,GAAG,IAAI,GAAG,SAAS,KAAU,aAAa;AAA5E,wBAWG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array.d.ts","sourceRoot":"","sources":["../../../src/utils/array.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,UAAW,GAAG,EAAE,
|
|
1
|
+
{"version":3,"file":"array.d.ts","sourceRoot":"","sources":["../../../src/utils/array.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,UAAW,GAAG,EAAE,UAAU,CAAC,GAAG,IAAI,EAAE,MAAM,GAAG,CAAC,KAAK,GAAG,KAAG,MAUhF,CAAC"}
|
|
@@ -74,12 +74,14 @@ describe('Retrieving headers', () => {
|
|
|
74
74
|
});
|
|
75
75
|
describe('Calling fetch', () => {
|
|
76
76
|
it('should call fetch without body but query string in get method', async () => {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
77
|
+
Object.defineProperty(global, 'fetch', {
|
|
78
|
+
value: jest.fn(() => Promise.resolve({
|
|
79
|
+
json: () => Promise.resolve({}),
|
|
80
|
+
headers: {
|
|
81
|
+
get: () => '',
|
|
82
|
+
},
|
|
83
|
+
})),
|
|
84
|
+
});
|
|
83
85
|
await new ApiRequester({
|
|
84
86
|
server,
|
|
85
87
|
agent: null,
|
|
@@ -99,15 +101,17 @@ describe('Calling fetch', () => {
|
|
|
99
101
|
describe('With a refresh token', () => {
|
|
100
102
|
it('should retry the call with a new token', async () => {
|
|
101
103
|
let calls = 0;
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
104
|
+
Object.defineProperty(global, 'fetch', {
|
|
105
|
+
value: jest.fn(() => {
|
|
106
|
+
calls++;
|
|
107
|
+
return Promise.resolve({
|
|
108
|
+
headers: {
|
|
109
|
+
get: () => 'application/json',
|
|
110
|
+
},
|
|
111
|
+
status: calls === 1 ? 401 : 200,
|
|
112
|
+
json: () => Promise.resolve({}),
|
|
113
|
+
});
|
|
114
|
+
}),
|
|
111
115
|
});
|
|
112
116
|
const requester = new ApiRequester({
|
|
113
117
|
server,
|
package/esm/web-rtc-client.js
CHANGED
package/esm/websocket-client.js
CHANGED
|
@@ -218,7 +218,7 @@ class WebSocketClient extends Emitter {
|
|
|
218
218
|
logger.warn('Trying to close an already closed websocket, bailing.', { url: this._getUrl() });
|
|
219
219
|
return;
|
|
220
220
|
}
|
|
221
|
-
this.socket.close();
|
|
221
|
+
this.socket.close(1000);
|
|
222
222
|
this.initialized = false;
|
|
223
223
|
if (force) {
|
|
224
224
|
this.host = null;
|
|
@@ -87,7 +87,9 @@ client.setToken(token);
|
|
|
87
87
|
describe('With correct API results', () => {
|
|
88
88
|
beforeEach(() => {
|
|
89
89
|
jest.resetModules();
|
|
90
|
-
|
|
90
|
+
Object.defineProperty(global, 'fetch', {
|
|
91
|
+
value: jest.fn(() => Promise.resolve(mockedJson)),
|
|
92
|
+
});
|
|
91
93
|
});
|
|
92
94
|
describe('logIn test', () => {
|
|
93
95
|
it('should retrieve user token', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -131,7 +133,9 @@ describe('With correct API results', () => {
|
|
|
131
133
|
describe('With unAuthorized API results', () => {
|
|
132
134
|
beforeEach(() => {
|
|
133
135
|
jest.resetModules();
|
|
134
|
-
|
|
136
|
+
Object.defineProperty(global, 'fetch', {
|
|
137
|
+
value: jest.fn(() => Promise.resolve(mockedUnAuthorized)),
|
|
138
|
+
});
|
|
135
139
|
});
|
|
136
140
|
describe('checkLogin test', () => {
|
|
137
141
|
it('should return false on 401 status', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -151,7 +155,9 @@ describe('With unAuthorized API results', () => {
|
|
|
151
155
|
describe('With not found API results', () => {
|
|
152
156
|
beforeEach(() => {
|
|
153
157
|
jest.resetModules();
|
|
154
|
-
|
|
158
|
+
Object.defineProperty(global, 'fetch', {
|
|
159
|
+
value: jest.fn(() => Promise.resolve(mockedNotFound)),
|
|
160
|
+
});
|
|
155
161
|
});
|
|
156
162
|
describe('fetchVoicemail test', () => {
|
|
157
163
|
it('should throw a BadResponse instance on 404 status', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -183,7 +189,9 @@ describe('With not found API results', () => {
|
|
|
183
189
|
describe('With erroneous text API results', () => {
|
|
184
190
|
beforeEach(() => {
|
|
185
191
|
jest.resetModules();
|
|
186
|
-
|
|
192
|
+
Object.defineProperty(global, 'fetch', {
|
|
193
|
+
value: jest.fn(() => Promise.resolve(mockedTextError)),
|
|
194
|
+
});
|
|
187
195
|
});
|
|
188
196
|
it('throw an exception when the response is >= 500', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
189
197
|
let error = null;
|
|
@@ -205,7 +213,9 @@ describe('With erroneous text API results', () => {
|
|
|
205
213
|
describe('With erroneous json API results', () => {
|
|
206
214
|
beforeEach(() => {
|
|
207
215
|
jest.resetModules();
|
|
208
|
-
|
|
216
|
+
Object.defineProperty(global, 'fetch', {
|
|
217
|
+
value: jest.fn(() => Promise.resolve(mockedJsonError)),
|
|
218
|
+
});
|
|
209
219
|
});
|
|
210
220
|
it('throw an exception when the response is >= 500', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
211
221
|
let error = null;
|
package/lib/checker/Checker.js
CHANGED
|
@@ -23,8 +23,8 @@ class Checker {
|
|
|
23
23
|
this.externalAppConfig = externalAppConfig;
|
|
24
24
|
this.checks = [...index_1.default];
|
|
25
25
|
}
|
|
26
|
-
check(
|
|
27
|
-
return __awaiter(this,
|
|
26
|
+
check() {
|
|
27
|
+
return __awaiter(this, arguments, void 0, function* (onCheckBegin = () => { }, onCheckResult = () => { }) {
|
|
28
28
|
yield this._addEngineVersion();
|
|
29
29
|
logger.info('Engine check starting');
|
|
30
30
|
for (let i = 0; i < this.checks.length; i++) {
|
|
@@ -118,8 +118,8 @@ class WebRTCPhone extends Emitter_1.default {
|
|
|
118
118
|
isWebRTC() {
|
|
119
119
|
return true;
|
|
120
120
|
}
|
|
121
|
-
sendReinvite(
|
|
122
|
-
return __awaiter(this,
|
|
121
|
+
sendReinvite(callSession_1) {
|
|
122
|
+
return __awaiter(this, arguments, void 0, function* (callSession, constraints = null, conference = false, audioOnly = false, iceRestart = false) {
|
|
123
123
|
const sipSession = this.findSipSession(callSession);
|
|
124
124
|
logger.info('WebRTC phone - send reinvite', {
|
|
125
125
|
sessionId: sipSession ? sipSession.id : null,
|
|
@@ -394,8 +394,8 @@ class WebRTCPhone extends Emitter_1.default {
|
|
|
394
394
|
return screenShareStream;
|
|
395
395
|
});
|
|
396
396
|
}
|
|
397
|
-
stopScreenSharing(
|
|
398
|
-
return __awaiter(this,
|
|
397
|
+
stopScreenSharing() {
|
|
398
|
+
return __awaiter(this, arguments, void 0, function* (restoreLocalStream = true, callSession) {
|
|
399
399
|
if (!this.currentScreenShare) {
|
|
400
400
|
return;
|
|
401
401
|
}
|
|
@@ -792,8 +792,8 @@ class WebRTCPhone extends Emitter_1.default {
|
|
|
792
792
|
}
|
|
793
793
|
return promise;
|
|
794
794
|
}
|
|
795
|
-
holdSipSession(
|
|
796
|
-
return __awaiter(this,
|
|
795
|
+
holdSipSession(sipSession_1, callSession_1) {
|
|
796
|
+
return __awaiter(this, arguments, void 0, function* (sipSession, callSession, withEvent = true) {
|
|
797
797
|
if (!sipSession) {
|
|
798
798
|
return new Promise((resolve, reject) => reject(new Error('No session to hold')));
|
|
799
799
|
}
|
|
@@ -820,8 +820,8 @@ class WebRTCPhone extends Emitter_1.default {
|
|
|
820
820
|
return promise;
|
|
821
821
|
});
|
|
822
822
|
}
|
|
823
|
-
unholdSipSession(
|
|
824
|
-
return __awaiter(this,
|
|
823
|
+
unholdSipSession(sipSession_1, callSession_1) {
|
|
824
|
+
return __awaiter(this, arguments, void 0, function* (sipSession, callSession, withEvent = true) {
|
|
825
825
|
if (!sipSession) {
|
|
826
826
|
return new Promise((resolve, reject) => reject(new Error('No session to unhold')));
|
|
827
827
|
}
|
|
@@ -956,8 +956,8 @@ class WebRTCPhone extends Emitter_1.default {
|
|
|
956
956
|
}
|
|
957
957
|
// Should be async to match CTIPhone definition
|
|
958
958
|
// @TODO: line is not used here
|
|
959
|
-
makeCall(
|
|
960
|
-
return __awaiter(this,
|
|
959
|
+
makeCall(number_1, line_1, cameraEnabled_1) {
|
|
960
|
+
return __awaiter(this, arguments, void 0, function* (number, line, cameraEnabled, audioOnly = false, conference = false, options = {}) {
|
|
961
961
|
logger.info('make WebRTC call', {
|
|
962
962
|
number,
|
|
963
963
|
lineId: line ? line.id : null,
|
|
@@ -1118,8 +1118,8 @@ class WebRTCPhone extends Emitter_1.default {
|
|
|
1118
1118
|
}
|
|
1119
1119
|
return this.client && this.client.isConference(callSession.sipCallId);
|
|
1120
1120
|
}
|
|
1121
|
-
close(
|
|
1122
|
-
return __awaiter(this,
|
|
1121
|
+
close() {
|
|
1122
|
+
return __awaiter(this, arguments, void 0, function* (force = false) {
|
|
1123
1123
|
logger.info('WebRTC close');
|
|
1124
1124
|
try {
|
|
1125
1125
|
yield Promise.race([
|
package/lib/service/CallApi.js
CHANGED
|
@@ -20,8 +20,8 @@ class CallApi {
|
|
|
20
20
|
return (0, getApiClient_1.default)().callLogd.listCallLogs(offset, limit);
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
|
-
static fetchDistinctCallLogs(
|
|
24
|
-
return __awaiter(this,
|
|
23
|
+
static fetchDistinctCallLogs(offset_1, limit_1) {
|
|
24
|
+
return __awaiter(this, arguments, void 0, function* (offset, limit, distinct = 'peer_exten') {
|
|
25
25
|
return (0, getApiClient_1.default)().callLogd.listDistinctCallLogs(offset, limit, distinct);
|
|
26
26
|
});
|
|
27
27
|
}
|
|
@@ -56,8 +56,8 @@ class CallApi {
|
|
|
56
56
|
return (0, getApiClient_1.default)().calld.cancelCall(callSession.callId);
|
|
57
57
|
});
|
|
58
58
|
}
|
|
59
|
-
static makeCall(
|
|
60
|
-
return __awaiter(this,
|
|
59
|
+
static makeCall(callFromLine_1, extension_1) {
|
|
60
|
+
return __awaiter(this, arguments, void 0, function* (callFromLine, extension, isMobile = false, callbackAllLines = false) {
|
|
61
61
|
const lineId = callFromLine ? callFromLine.id : null;
|
|
62
62
|
const response = yield (0, getApiClient_1.default)().calld.makeCall(extension, isMobile, lineId, callbackAllLines);
|
|
63
63
|
return Call_1.default.parse(response);
|
|
@@ -22,7 +22,11 @@ describe('IssueReporter', () => {
|
|
|
22
22
|
});
|
|
23
23
|
beforeEach(() => {
|
|
24
24
|
jest.resetAllMocks();
|
|
25
|
-
|
|
25
|
+
Object.defineProperty(global, 'fetch', {
|
|
26
|
+
value: jest.fn(() => ({
|
|
27
|
+
catch: () => { },
|
|
28
|
+
})),
|
|
29
|
+
});
|
|
26
30
|
});
|
|
27
31
|
afterAll(() => {
|
|
28
32
|
console.log = oldLog;
|
package/lib/simple/Auth.js
CHANGED
|
@@ -176,9 +176,9 @@ class Auth {
|
|
|
176
176
|
return (0, getApiClient_1.default)().auth.refreshToken(refreshToken, '', this.expiration);
|
|
177
177
|
});
|
|
178
178
|
}
|
|
179
|
-
logout(
|
|
180
|
-
|
|
181
|
-
|
|
179
|
+
logout() {
|
|
180
|
+
return __awaiter(this, arguments, void 0, function* (deleteRefreshToken = true) {
|
|
181
|
+
var _a;
|
|
182
182
|
try {
|
|
183
183
|
index_1.default.Websocket.close(true);
|
|
184
184
|
if (this.clientId && deleteRefreshToken) {
|
|
@@ -302,8 +302,8 @@ class Auth {
|
|
|
302
302
|
(0, getApiClient_1.setFetchOptions)(Object.assign(Object.assign({}, (0, getApiClient_1.getFetchOptions)()), { headers }));
|
|
303
303
|
}
|
|
304
304
|
checkHttpUserUuidHeader(uuid) {
|
|
305
|
-
var _a;
|
|
306
305
|
return __awaiter(this, void 0, void 0, function* () {
|
|
306
|
+
var _a;
|
|
307
307
|
logger.info('Checking user uuid http header', { uuid });
|
|
308
308
|
if (!uuid) {
|
|
309
309
|
return;
|
|
@@ -331,8 +331,8 @@ class Auth {
|
|
|
331
331
|
});
|
|
332
332
|
}
|
|
333
333
|
_onAuthenticated(rawSession) {
|
|
334
|
-
var _a;
|
|
335
334
|
return __awaiter(this, void 0, void 0, function* () {
|
|
335
|
+
var _a;
|
|
336
336
|
if (this.authenticated && this.session) {
|
|
337
337
|
return this.session;
|
|
338
338
|
}
|
package/lib/simple/Phone.js
CHANGED
|
@@ -59,8 +59,8 @@ class Phone extends Emitter_1.default {
|
|
|
59
59
|
});
|
|
60
60
|
this.SessionState = session_state_1.SessionState;
|
|
61
61
|
}
|
|
62
|
-
connect(
|
|
63
|
-
return __awaiter(this,
|
|
62
|
+
connect() {
|
|
63
|
+
return __awaiter(this, arguments, void 0, function* (rawOptions = {}, sipLine = null) {
|
|
64
64
|
const options = rawOptions;
|
|
65
65
|
if (this.phone) {
|
|
66
66
|
// Already connected
|
|
@@ -120,8 +120,8 @@ class Phone extends Emitter_1.default {
|
|
|
120
120
|
});
|
|
121
121
|
}
|
|
122
122
|
// If audioOnly is set to true, all video stream will be deactivated, even remotes ones.
|
|
123
|
-
call(
|
|
124
|
-
return __awaiter(this,
|
|
123
|
+
call(extension_1) {
|
|
124
|
+
return __awaiter(this, arguments, void 0, function* (extension, withCamera = false, rawSipLine = null, audioOnly = false, conference = false) {
|
|
125
125
|
if (!this.phone) {
|
|
126
126
|
return;
|
|
127
127
|
}
|
|
@@ -196,14 +196,14 @@ class Phone extends Emitter_1.default {
|
|
|
196
196
|
return (_a = this.phone) === null || _a === void 0 ? void 0 : _a.hold(callSession, true);
|
|
197
197
|
}
|
|
198
198
|
unhold(callSession) {
|
|
199
|
-
var _a;
|
|
200
199
|
return __awaiter(this, void 0, void 0, function* () {
|
|
200
|
+
var _a;
|
|
201
201
|
return (_a = this.phone) === null || _a === void 0 ? void 0 : _a.unhold(callSession, true);
|
|
202
202
|
});
|
|
203
203
|
}
|
|
204
204
|
resume(callSession) {
|
|
205
|
-
var _a;
|
|
206
205
|
return __awaiter(this, void 0, void 0, function* () {
|
|
206
|
+
var _a;
|
|
207
207
|
return ((_a = this.phone) === null || _a === void 0 ? void 0 : _a.resume(callSession)) || null;
|
|
208
208
|
});
|
|
209
209
|
}
|
|
@@ -219,8 +219,8 @@ class Phone extends Emitter_1.default {
|
|
|
219
219
|
var _a;
|
|
220
220
|
return ((_a = this.phone) === null || _a === void 0 ? void 0 : _a.atxfer(callSession)) || null;
|
|
221
221
|
}
|
|
222
|
-
reinvite(
|
|
223
|
-
return __awaiter(this,
|
|
222
|
+
reinvite(callSession_1) {
|
|
223
|
+
return __awaiter(this, arguments, void 0, function* (callSession, constraints = null, conference = false) {
|
|
224
224
|
return this.phone ? this.phone.sendReinvite(callSession, constraints, conference) : null;
|
|
225
225
|
});
|
|
226
226
|
}
|
|
@@ -269,8 +269,8 @@ class Phone extends Emitter_1.default {
|
|
|
269
269
|
(_a = this.phone) === null || _a === void 0 ? void 0 : _a.turnCameraOn(callSession);
|
|
270
270
|
}
|
|
271
271
|
startScreenSharing(constraints, callSession) {
|
|
272
|
-
var _a;
|
|
273
272
|
return __awaiter(this, void 0, void 0, function* () {
|
|
273
|
+
var _a;
|
|
274
274
|
return ((_a = this.phone) === null || _a === void 0 ? void 0 : _a.startScreenSharing(constraints, callSession)) || null;
|
|
275
275
|
});
|
|
276
276
|
}
|
|
@@ -277,8 +277,8 @@ class Participant extends Emitter_1.default {
|
|
|
277
277
|
this.streams = streams;
|
|
278
278
|
this.videoStreams = streams;
|
|
279
279
|
}
|
|
280
|
-
ban(
|
|
281
|
-
return __awaiter(this,
|
|
280
|
+
ban() {
|
|
281
|
+
return __awaiter(this, arguments, void 0, function* (apiRequestDelay = null) {
|
|
282
282
|
const { meetingUuid, } = this.room || {};
|
|
283
283
|
if (!meetingUuid) {
|
|
284
284
|
throw new Error('Attempting to ban a participant without a `meetingUuid`');
|
package/lib/simple/room/Room.js
CHANGED
|
@@ -95,8 +95,8 @@ class Room extends Emitter_1.default {
|
|
|
95
95
|
* @param meeting ?Meeting
|
|
96
96
|
* @returns {Promise<Room>}
|
|
97
97
|
*/
|
|
98
|
-
static connect(
|
|
99
|
-
return __awaiter(this,
|
|
98
|
+
static connect(_a) {
|
|
99
|
+
return __awaiter(this, arguments, void 0, function* ({ extension, constraints, audioOnly = false, extra, room, meeting, }) {
|
|
100
100
|
logger.info('connecting to room', {
|
|
101
101
|
extension,
|
|
102
102
|
audioOnly,
|
|
@@ -165,8 +165,8 @@ class Room extends Emitter_1.default {
|
|
|
165
165
|
index_1.default.Phone.disconnect();
|
|
166
166
|
}
|
|
167
167
|
disconnect() {
|
|
168
|
-
var _a;
|
|
169
168
|
return __awaiter(this, void 0, void 0, function* () {
|
|
169
|
+
var _a;
|
|
170
170
|
logger.info('disconnection to room called');
|
|
171
171
|
yield index_1.default.Phone.hangup(this.callSession);
|
|
172
172
|
this.callSession = undefined;
|
|
@@ -234,8 +234,8 @@ class Room extends Emitter_1.default {
|
|
|
234
234
|
return screensharingStream;
|
|
235
235
|
});
|
|
236
236
|
}
|
|
237
|
-
stopScreenSharing(
|
|
238
|
-
return __awaiter(this,
|
|
237
|
+
stopScreenSharing() {
|
|
238
|
+
return __awaiter(this, arguments, void 0, function* (restoreLocalStream = true) {
|
|
239
239
|
logger.info('stop room screen sharing');
|
|
240
240
|
yield index_1.default.Phone.stopScreenSharing(this.callSession, restoreLocalStream);
|
|
241
241
|
if (this.localParticipant) {
|
|
@@ -312,9 +312,9 @@ class Room extends Emitter_1.default {
|
|
|
312
312
|
});
|
|
313
313
|
index_1.default.Phone.sendDTMF(tone, this.callSession);
|
|
314
314
|
}
|
|
315
|
-
sendReinvite(
|
|
316
|
-
|
|
317
|
-
|
|
315
|
+
sendReinvite() {
|
|
316
|
+
return __awaiter(this, arguments, void 0, function* (newConstraints = null) {
|
|
317
|
+
var _a, _b;
|
|
318
318
|
logger.info('send room reinvite', {
|
|
319
319
|
callId: this.callSession ? this.callSession.getId() : null,
|
|
320
320
|
newConstraints,
|
|
@@ -17,8 +17,8 @@ const index_1 = __importDefault(require("../index"));
|
|
|
17
17
|
const Room_1 = __importDefault(require("./Room"));
|
|
18
18
|
const logger = IssueReporter_1.default.loggerFor('sdk-sip-room');
|
|
19
19
|
class SipRoom extends Room_1.default {
|
|
20
|
-
static connect(
|
|
21
|
-
return __awaiter(this,
|
|
20
|
+
static connect(_a) {
|
|
21
|
+
return __awaiter(this, arguments, void 0, function* ({ extension, constraints, audioOnly = false, extra, room, }) {
|
|
22
22
|
logger.info('connecting to sip room', {
|
|
23
23
|
extension,
|
|
24
24
|
audioOnly,
|
package/lib/simple/utils.js
CHANGED
|
@@ -15,7 +15,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
exports.createLocalAudioStream = exports.createLocalVideoStream = void 0;
|
|
16
16
|
/* global navigator */
|
|
17
17
|
const index_1 = __importDefault(require("./index"));
|
|
18
|
-
const createLocalStream = (
|
|
18
|
+
const createLocalStream = (kind_1, ...args_1) => __awaiter(void 0, [kind_1, ...args_1], void 0, function* (kind, options = {}) {
|
|
19
19
|
const createOptions = {};
|
|
20
20
|
createOptions[kind] = Object.keys(options).length > 0 ? options : true;
|
|
21
21
|
const mediaStream = yield navigator.mediaDevices.getUserMedia(createOptions);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getApiClient.d.ts","sourceRoot":"","sources":["../../../src/service/getApiClient.ts"],"names":[],"mappings":"AACA,OAAO,aAAa,MAAM,eAAe,CAAC;AAkB1C,eAAO,MAAM,cAAc,aAAc,MAAM,cAAa,MAAM,GAAG,IAAI,GAAG,SAAS,SAEpF,CAAC;AACF,eAAO,MAAM,gBAAgB,cAAe,MAAM,SAEjD,CAAC;AACF,eAAO,MAAM,WAAW,aAAc,MAAM,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Aa,MAAM,GAAG,IAAI,GAAG,SAAS,SAEnH,CAAC;AACF,eAAO,MAAM,sBAAsB,aAAc,CAAC,GAAG,IAAI,EAAE,MAAM,GAAG,CAAC,KAAK,GAAG,cAAa,MAAM,GAAG,IAAI,GAAG,SAAS,SAElH,CAAC;AACF,eAAO,MAAM,oBAAoB,sBAAuB,MAAM,cAAa,MAAM,GAAG,IAAI,GAAG,SAAS,SAEnG,CAAC;AACF,eAAO,MAAM,iBAAiB,mBAAoB,MAAM,cAAa,MAAM,GAAG,IAAI,GAAG,SAAS,SAE7F,CAAC;AACF,eAAO,MAAM,WAAW,aAAc,OAAO,cAAa,MAAM,GAAG,IAAI,GAAG,SAAS,SAElF,CAAC;AACF,eAAO,MAAM,iBAAiB,mBAAoB,MAAM,cAAa,MAAM,GAAG,IAAI,GAAG,SAAS,SAE7F,CAAC;AACF,eAAO,MAAM,eAAe,iBAAkB,OAAO,MAAM,EAAE,GAAG,CAAC,cAAa,MAAM,GAAG,IAAI,GAAG,SAAS,SAEtG,CAAC;AACF,eAAO,MAAM,eAAe,eAAe,MAAM,GAAG,IAAI,GAAG,SAAS,QAC6C,CAAC;qCAkCtF,MAAM,GAAG,IAAI,GAAG,SAAS,KAAU,aAAa;AAA5E,wBAWG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array.d.ts","sourceRoot":"","sources":["../../../src/utils/array.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,UAAW,GAAG,EAAE,
|
|
1
|
+
{"version":3,"file":"array.d.ts","sourceRoot":"","sources":["../../../src/utils/array.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,UAAW,GAAG,EAAE,UAAU,CAAC,GAAG,IAAI,EAAE,MAAM,GAAG,CAAC,KAAK,GAAG,KAAG,MAUhF,CAAC"}
|
|
@@ -88,12 +88,14 @@ describe('Retrieving headers', () => {
|
|
|
88
88
|
});
|
|
89
89
|
describe('Calling fetch', () => {
|
|
90
90
|
it('should call fetch without body but query string in get method', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
91
|
+
Object.defineProperty(global, 'fetch', {
|
|
92
|
+
value: jest.fn(() => Promise.resolve({
|
|
93
|
+
json: () => Promise.resolve({}),
|
|
94
|
+
headers: {
|
|
95
|
+
get: () => '',
|
|
96
|
+
},
|
|
97
|
+
})),
|
|
98
|
+
});
|
|
97
99
|
yield new api_requester_1.default({
|
|
98
100
|
server,
|
|
99
101
|
agent: null,
|
|
@@ -113,15 +115,17 @@ describe('Calling fetch', () => {
|
|
|
113
115
|
describe('With a refresh token', () => {
|
|
114
116
|
it('should retry the call with a new token', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
115
117
|
let calls = 0;
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
118
|
+
Object.defineProperty(global, 'fetch', {
|
|
119
|
+
value: jest.fn(() => {
|
|
120
|
+
calls++;
|
|
121
|
+
return Promise.resolve({
|
|
122
|
+
headers: {
|
|
123
|
+
get: () => 'application/json',
|
|
124
|
+
},
|
|
125
|
+
status: calls === 1 ? 401 : 200,
|
|
126
|
+
json: () => Promise.resolve({}),
|
|
127
|
+
});
|
|
128
|
+
}),
|
|
125
129
|
});
|
|
126
130
|
const requester = new api_requester_1.default({
|
|
127
131
|
server,
|
|
@@ -73,8 +73,8 @@ class ApiRequester {
|
|
|
73
73
|
enableErrorLogging() {
|
|
74
74
|
this.shouldLogErrors = true;
|
|
75
75
|
}
|
|
76
|
-
call(
|
|
77
|
-
return __awaiter(this,
|
|
76
|
+
call(path_1) {
|
|
77
|
+
return __awaiter(this, arguments, void 0, function* (path, method = 'get', body = null, headers = null, parse = ApiRequester.defaultParser, firstCall = true) {
|
|
78
78
|
const url = this.computeUrl(method, path, body);
|
|
79
79
|
const newHeaders = this.getHeaders(headers);
|
|
80
80
|
let newBody = method === 'get' ? null : body;
|