@wazo/sdk 0.37.24 → 0.37.28
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 +96 -58
- package/dist/wazo-sdk.js +6 -6
- package/esm/__tests__/api-client.test.js +14 -14
- package/esm/__tests__/web-rtc-client.test.js +130 -108
- package/esm/api/agentd.js +1 -1
- package/esm/api/amid.js +2 -2
- package/esm/api/application.js +1 -1
- package/esm/api/auth.js +1 -1
- package/esm/api/call-logd.js +3 -3
- package/esm/api/calld.js +1 -1
- package/esm/api/chatd.js +1 -1
- package/esm/api/confd.js +1 -1
- package/esm/api/ctid-ng.js +4 -4
- package/esm/api/dird.js +3 -3
- package/esm/api/webhookd.js +2 -2
- package/esm/api-client.js +14 -14
- package/esm/checker/Checker.js +155 -133
- package/esm/checker/checks/aor.js +14 -14
- package/esm/checker/checks/api.js +14 -14
- package/esm/checker/checks/index.js +145 -123
- package/esm/checker/checks/wazo-websocket.js +16 -16
- package/esm/checker/checks/webrtc-transport.js +130 -108
- package/esm/checker/checks/webrtc.js +130 -108
- package/esm/domain/AdHocAPIConference.js +14 -14
- package/esm/domain/CallLog.js +1 -1
- package/esm/domain/CallSession.js +15 -0
- package/esm/domain/Contact.js +2 -2
- package/esm/domain/Features.js +14 -14
- package/esm/domain/Phone/CTIPhone.js +43 -28
- package/esm/domain/Phone/WebRTCPhone.js +126 -90
- package/esm/domain/SFUNotAvailableError.js +9 -0
- package/esm/domain/__tests__/CallLog.test.js +1 -1
- package/esm/domain/__tests__/CallSession.test.js +15 -0
- package/esm/domain/__tests__/Contact.test.js +2 -2
- package/esm/domain/__tests__/IndirectTransfer.test.js +15 -0
- package/esm/domain/__tests__/Room.test.js +15 -0
- package/esm/index.js +415 -346
- package/esm/lib/WazoSessionDescriptionHandler.js +10 -5
- package/esm/service/CallApi.js +14 -14
- package/esm/service/IssueReporter.js +2 -2
- package/esm/service/__tests__/IssueReporter.test.js +2 -2
- package/esm/service/getApiClient.js +14 -14
- package/esm/simple/Auth.js +404 -336
- package/esm/simple/Configuration.js +404 -336
- package/esm/simple/Directory.js +14 -14
- package/esm/simple/Phone.js +404 -336
- package/esm/simple/Websocket.js +18 -18
- package/esm/simple/index.js +408 -340
- package/esm/simple/room/LocalParticipant.js +408 -340
- package/esm/simple/room/Participant.js +408 -340
- package/esm/simple/room/RemoteParticipant.js +408 -340
- package/esm/simple/room/Room.js +409 -341
- package/esm/simple/room/SipRoom.js +408 -340
- package/esm/simple/room/Stream.js +408 -340
- package/esm/simple/room/__tests__/RemoteParticipant.test.js +408 -340
- package/esm/simple/utils.js +408 -340
- package/esm/utils/__tests__/api-requester.test.js +1 -1
- package/esm/utils/api-requester.js +1 -1
- package/esm/web-rtc-client.js +130 -108
- package/esm/websocket-client.js +16 -16
- package/lib/__tests__/api-client.test.js +14 -14
- package/lib/__tests__/web-rtc-client.test.js +130 -108
- package/lib/api/agentd.js +1 -1
- package/lib/api/amid.js +2 -2
- package/lib/api/application.js +1 -1
- package/lib/api/auth.js +1 -1
- package/lib/api/call-logd.js +3 -3
- package/lib/api/calld.js +1 -1
- package/lib/api/chatd.js +1 -1
- package/lib/api/confd.js +1 -1
- package/lib/api/ctid-ng.js +4 -4
- package/lib/api/dird.js +3 -3
- package/lib/api/webhookd.js +2 -2
- package/lib/api-client.js +14 -14
- package/lib/checker/Checker.js +155 -133
- package/lib/checker/checks/aor.js +14 -14
- package/lib/checker/checks/api.js +14 -14
- package/lib/checker/checks/index.js +145 -123
- package/lib/checker/checks/wazo-websocket.js +16 -16
- package/lib/checker/checks/webrtc-transport.js +130 -108
- package/lib/checker/checks/webrtc.js +130 -108
- package/lib/domain/AdHocAPIConference.js +14 -14
- package/lib/domain/CallLog.js +1 -1
- package/lib/domain/CallSession.js +15 -0
- package/lib/domain/Contact.js +2 -2
- package/lib/domain/Features.js +14 -14
- package/lib/domain/Phone/CTIPhone.js +43 -28
- package/lib/domain/Phone/WebRTCPhone.js +126 -89
- package/lib/domain/SFUNotAvailableError.js +11 -0
- package/lib/domain/__tests__/CallLog.test.js +1 -1
- package/lib/domain/__tests__/CallSession.test.js +15 -0
- package/lib/domain/__tests__/Contact.test.js +2 -2
- package/lib/domain/__tests__/IndirectTransfer.test.js +15 -0
- package/lib/domain/__tests__/Room.test.js +15 -0
- package/lib/index.js +415 -346
- package/lib/lib/WazoSessionDescriptionHandler.js +10 -5
- package/lib/service/CallApi.js +14 -14
- package/lib/service/IssueReporter.js +2 -2
- package/lib/service/__tests__/IssueReporter.test.js +2 -2
- package/lib/service/getApiClient.js +14 -14
- package/lib/simple/Auth.js +404 -336
- package/lib/simple/Configuration.js +404 -336
- package/lib/simple/Directory.js +14 -14
- package/lib/simple/Phone.js +404 -336
- package/lib/simple/Websocket.js +18 -18
- package/lib/simple/index.js +408 -340
- package/lib/simple/room/LocalParticipant.js +408 -340
- package/lib/simple/room/Participant.js +408 -340
- package/lib/simple/room/RemoteParticipant.js +408 -340
- package/lib/simple/room/Room.js +409 -341
- package/lib/simple/room/SipRoom.js +408 -340
- package/lib/simple/room/Stream.js +408 -340
- package/lib/simple/room/__tests__/RemoteParticipant.test.js +408 -340
- package/lib/simple/utils.js +408 -340
- package/lib/utils/__tests__/api-requester.test.js +1 -1
- package/lib/utils/api-requester.js +1 -1
- package/lib/web-rtc-client.js +130 -108
- package/lib/websocket-client.js +16 -16
- package/package.json +1 -1
- package/src/domain/CallSession.js +16 -0
- package/src/domain/Contact.js +1 -1
- package/src/domain/Phone/WebRTCPhone.js +25 -4
- package/src/domain/SFUNotAvailableError.js +7 -0
- package/src/index.js +2 -0
- package/src/lib/WazoSessionDescriptionHandler.js +8 -3
- package/src/simple/Phone.js +2 -1
- package/src/simple/index.js +2 -0
- package/src/utils/api-requester.js +1 -1
- package/src/web-rtc-client.js +27 -10
|
@@ -11,11 +11,11 @@ const isMobile = () => typeof navigator !== 'undefined' && navigator.product ===
|
|
|
11
11
|
|
|
12
12
|
/* */
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
15
15
|
|
|
16
16
|
// Use a function here to be able to mock it in tests
|
|
17
17
|
const realFetch = () => {
|
|
18
|
-
if (typeof document !== 'undefined') {
|
|
18
|
+
if (typeof document !== 'undefined' && window.fetch) {
|
|
19
19
|
// Browser
|
|
20
20
|
return window.fetch;
|
|
21
21
|
}
|
|
@@ -487,11 +487,16 @@ class WazoSessionDescriptionHandler extends SessionDescriptionHandler {
|
|
|
487
487
|
|
|
488
488
|
// $FlowFixMe
|
|
489
489
|
setRemoteSessionDescription(sessionDescription ) {
|
|
490
|
-
|
|
490
|
+
try {
|
|
491
|
+
const result = super.setRemoteSessionDescription(sessionDescription);
|
|
491
492
|
|
|
492
|
-
|
|
493
|
+
this.eventEmitter.emit('setDescription', sessionDescription);
|
|
493
494
|
|
|
494
|
-
|
|
495
|
+
return result;
|
|
496
|
+
} catch (error) {
|
|
497
|
+
this.logger.error('SessionDescriptionHandler.setRemoteSessionDescription error', error);
|
|
498
|
+
throw error;
|
|
499
|
+
}
|
|
495
500
|
}
|
|
496
501
|
|
|
497
502
|
// Overridden to avoid to fix ice-candidates missing in the SDP in react-native and chrome canary.
|
package/esm/service/CallApi.js
CHANGED
|
@@ -1410,7 +1410,7 @@ class Contact {
|
|
|
1410
1410
|
this[key] = old[key] || this[key];
|
|
1411
1411
|
});
|
|
1412
1412
|
|
|
1413
|
-
if (old.lineState
|
|
1413
|
+
if (old.lineState) {
|
|
1414
1414
|
this.lineState = old.lineState;
|
|
1415
1415
|
}
|
|
1416
1416
|
|
|
@@ -2462,11 +2462,11 @@ var IssueReporter$1 = new IssueReporter();
|
|
|
2462
2462
|
|
|
2463
2463
|
const methods = ['head', 'get', 'post', 'put', 'delete'];
|
|
2464
2464
|
|
|
2465
|
-
const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
2465
|
+
const logger$1 = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
2466
2466
|
|
|
2467
2467
|
// Use a function here to be able to mock it in tests
|
|
2468
2468
|
const realFetch = () => {
|
|
2469
|
-
if (typeof document !== 'undefined') {
|
|
2469
|
+
if (typeof document !== 'undefined' && window.fetch) {
|
|
2470
2470
|
// Browser
|
|
2471
2471
|
return window.fetch;
|
|
2472
2472
|
}
|
|
@@ -2601,7 +2601,7 @@ class ApiRequester {
|
|
|
2601
2601
|
};
|
|
2602
2602
|
|
|
2603
2603
|
if (this.refreshTokenPromise) {
|
|
2604
|
-
logger.info('A token is already refreshing, waiting ...', { url });
|
|
2604
|
+
logger$1.info('A token is already refreshing, waiting ...', { url });
|
|
2605
2605
|
await this.refreshTokenPromise;
|
|
2606
2606
|
}
|
|
2607
2607
|
|
|
@@ -2621,7 +2621,7 @@ class ApiRequester {
|
|
|
2621
2621
|
return promise.then(async (err ) => {
|
|
2622
2622
|
// Check if the token is still valid
|
|
2623
2623
|
if (firstCall && this._checkTokenExpired(response, err)) {
|
|
2624
|
-
logger.warn('token expired', { error: err.reason });
|
|
2624
|
+
logger$1.warn('token expired', { error: err.reason });
|
|
2625
2625
|
// Replay the call after refreshing the token
|
|
2626
2626
|
return this._replayWithNewToken(err, path, method, body, headers, parse);
|
|
2627
2627
|
}
|
|
@@ -2631,7 +2631,7 @@ class ApiRequester {
|
|
|
2631
2631
|
: exceptionClass.fromResponse(err, response.status);
|
|
2632
2632
|
|
|
2633
2633
|
if (this.shouldLogErrors) {
|
|
2634
|
-
logger.error('API error', error);
|
|
2634
|
+
logger$1.error('API error', error);
|
|
2635
2635
|
}
|
|
2636
2636
|
|
|
2637
2637
|
throw error;
|
|
@@ -2641,7 +2641,7 @@ class ApiRequester {
|
|
|
2641
2641
|
return newParse(response, isJson);
|
|
2642
2642
|
}).catch(error => {
|
|
2643
2643
|
if (this.shouldLogErrors) {
|
|
2644
|
-
logger.error('Fetch failed', { url, options, message: error.message, stack: error.stack });
|
|
2644
|
+
logger$1.error('Fetch failed', { url, options, message: error.message, stack: error.stack });
|
|
2645
2645
|
}
|
|
2646
2646
|
|
|
2647
2647
|
throw error;
|
|
@@ -2669,13 +2669,13 @@ class ApiRequester {
|
|
|
2669
2669
|
) {
|
|
2670
2670
|
const isTokenNotFound = this._isTokenNotFound(err);
|
|
2671
2671
|
let newPath = path;
|
|
2672
|
-
logger.info('refreshing token', { inProgress: !!this.refreshTokenPromise });
|
|
2672
|
+
logger$1.info('refreshing token', { inProgress: !!this.refreshTokenPromise });
|
|
2673
2673
|
|
|
2674
2674
|
this.refreshTokenPromise = this.refreshTokenPromise || this.refreshTokenCallback();
|
|
2675
2675
|
|
|
2676
2676
|
return this.refreshTokenPromise.then(() => {
|
|
2677
2677
|
this.refreshTokenPromise = null;
|
|
2678
|
-
logger.info('token refreshed', { isTokenNotFound });
|
|
2678
|
+
logger$1.info('token refreshed', { isTokenNotFound });
|
|
2679
2679
|
if (isTokenNotFound) {
|
|
2680
2680
|
const pathParts = path.split('/');
|
|
2681
2681
|
pathParts.pop();
|
|
@@ -3512,7 +3512,7 @@ const TRANSFER_FLOW_BLIND = 'blind';
|
|
|
3512
3512
|
|
|
3513
3513
|
// const MINIMUM_WAZO_ENGINE_VERSION_FOR_CTI_HOLD = '20.11';
|
|
3514
3514
|
|
|
3515
|
-
|
|
3515
|
+
IssueReporter$1 ? IssueReporter$1.loggerFor('cti-phone') : console;
|
|
3516
3516
|
|
|
3517
3517
|
/* */
|
|
3518
3518
|
|
|
@@ -4499,7 +4499,7 @@ const AGENTD_VERSION = '1.0';
|
|
|
4499
4499
|
const WEBHOOKD_VERSION = '1.0';
|
|
4500
4500
|
const AMID_VERSION = '1.0';
|
|
4501
4501
|
|
|
4502
|
-
const logger
|
|
4502
|
+
const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
4503
4503
|
|
|
4504
4504
|
class ApiClient {
|
|
4505
4505
|
|
|
@@ -4551,12 +4551,12 @@ class ApiClient {
|
|
|
4551
4551
|
}
|
|
4552
4552
|
|
|
4553
4553
|
async forceRefreshToken() {
|
|
4554
|
-
logger
|
|
4554
|
+
logger.info('forcing refresh token, calling callback');
|
|
4555
4555
|
return this.refreshTokenCallback();
|
|
4556
4556
|
}
|
|
4557
4557
|
|
|
4558
4558
|
async refreshTokenCallback() {
|
|
4559
|
-
logger
|
|
4559
|
+
logger.info('refresh token callback called', {
|
|
4560
4560
|
refreshToken: this.refreshToken,
|
|
4561
4561
|
refreshBackend: this.refreshBackend,
|
|
4562
4562
|
refreshExpiration: this.refreshExpiration,
|
|
@@ -4574,7 +4574,7 @@ class ApiClient {
|
|
|
4574
4574
|
this.isMobile,
|
|
4575
4575
|
);
|
|
4576
4576
|
|
|
4577
|
-
logger
|
|
4577
|
+
logger.info('token refreshed', { token: session.token });
|
|
4578
4578
|
|
|
4579
4579
|
if (this.onRefreshToken) {
|
|
4580
4580
|
this.onRefreshToken(session.token, session);
|
|
@@ -7,11 +7,11 @@ const isMobile = () => typeof navigator !== 'undefined' && navigator.product ===
|
|
|
7
7
|
|
|
8
8
|
/* */
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
11
11
|
|
|
12
12
|
// Use a function here to be able to mock it in tests
|
|
13
13
|
const realFetch = () => {
|
|
14
|
-
if (typeof document !== 'undefined') {
|
|
14
|
+
if (typeof document !== 'undefined' && window.fetch) {
|
|
15
15
|
// Browser
|
|
16
16
|
return window.fetch;
|
|
17
17
|
}
|
|
@@ -7,11 +7,11 @@ const isMobile = () => typeof navigator !== 'undefined' && navigator.product ===
|
|
|
7
7
|
|
|
8
8
|
/* */
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
11
11
|
|
|
12
12
|
// Use a function here to be able to mock it in tests
|
|
13
13
|
const realFetch = () => {
|
|
14
|
-
if (typeof document !== 'undefined') {
|
|
14
|
+
if (typeof document !== 'undefined' && window.fetch) {
|
|
15
15
|
// Browser
|
|
16
16
|
return window.fetch;
|
|
17
17
|
}
|
|
@@ -440,11 +440,11 @@ var IssueReporter$1 = new IssueReporter();
|
|
|
440
440
|
|
|
441
441
|
const methods = ['head', 'get', 'post', 'put', 'delete'];
|
|
442
442
|
|
|
443
|
-
const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
443
|
+
const logger$1 = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
444
444
|
|
|
445
445
|
// Use a function here to be able to mock it in tests
|
|
446
446
|
const realFetch = () => {
|
|
447
|
-
if (typeof document !== 'undefined') {
|
|
447
|
+
if (typeof document !== 'undefined' && window.fetch) {
|
|
448
448
|
// Browser
|
|
449
449
|
return window.fetch;
|
|
450
450
|
}
|
|
@@ -579,7 +579,7 @@ class ApiRequester {
|
|
|
579
579
|
};
|
|
580
580
|
|
|
581
581
|
if (this.refreshTokenPromise) {
|
|
582
|
-
logger.info('A token is already refreshing, waiting ...', { url });
|
|
582
|
+
logger$1.info('A token is already refreshing, waiting ...', { url });
|
|
583
583
|
await this.refreshTokenPromise;
|
|
584
584
|
}
|
|
585
585
|
|
|
@@ -599,7 +599,7 @@ class ApiRequester {
|
|
|
599
599
|
return promise.then(async (err ) => {
|
|
600
600
|
// Check if the token is still valid
|
|
601
601
|
if (firstCall && this._checkTokenExpired(response, err)) {
|
|
602
|
-
logger.warn('token expired', { error: err.reason });
|
|
602
|
+
logger$1.warn('token expired', { error: err.reason });
|
|
603
603
|
// Replay the call after refreshing the token
|
|
604
604
|
return this._replayWithNewToken(err, path, method, body, headers, parse);
|
|
605
605
|
}
|
|
@@ -609,7 +609,7 @@ class ApiRequester {
|
|
|
609
609
|
: exceptionClass.fromResponse(err, response.status);
|
|
610
610
|
|
|
611
611
|
if (this.shouldLogErrors) {
|
|
612
|
-
logger.error('API error', error);
|
|
612
|
+
logger$1.error('API error', error);
|
|
613
613
|
}
|
|
614
614
|
|
|
615
615
|
throw error;
|
|
@@ -619,7 +619,7 @@ class ApiRequester {
|
|
|
619
619
|
return newParse(response, isJson);
|
|
620
620
|
}).catch(error => {
|
|
621
621
|
if (this.shouldLogErrors) {
|
|
622
|
-
logger.error('Fetch failed', { url, options, message: error.message, stack: error.stack });
|
|
622
|
+
logger$1.error('Fetch failed', { url, options, message: error.message, stack: error.stack });
|
|
623
623
|
}
|
|
624
624
|
|
|
625
625
|
throw error;
|
|
@@ -647,13 +647,13 @@ class ApiRequester {
|
|
|
647
647
|
) {
|
|
648
648
|
const isTokenNotFound = this._isTokenNotFound(err);
|
|
649
649
|
let newPath = path;
|
|
650
|
-
logger.info('refreshing token', { inProgress: !!this.refreshTokenPromise });
|
|
650
|
+
logger$1.info('refreshing token', { inProgress: !!this.refreshTokenPromise });
|
|
651
651
|
|
|
652
652
|
this.refreshTokenPromise = this.refreshTokenPromise || this.refreshTokenCallback();
|
|
653
653
|
|
|
654
654
|
return this.refreshTokenPromise.then(() => {
|
|
655
655
|
this.refreshTokenPromise = null;
|
|
656
|
-
logger.info('token refreshed', { isTokenNotFound });
|
|
656
|
+
logger$1.info('token refreshed', { isTokenNotFound });
|
|
657
657
|
if (isTokenNotFound) {
|
|
658
658
|
const pathParts = path.split('/');
|
|
659
659
|
pathParts.pop();
|
|
@@ -1904,7 +1904,7 @@ class Contact {
|
|
|
1904
1904
|
this[key] = old[key] || this[key];
|
|
1905
1905
|
});
|
|
1906
1906
|
|
|
1907
|
-
if (old.lineState
|
|
1907
|
+
if (old.lineState) {
|
|
1908
1908
|
this.lineState = old.lineState;
|
|
1909
1909
|
}
|
|
1910
1910
|
|
|
@@ -3580,7 +3580,7 @@ const TRANSFER_FLOW_BLIND = 'blind';
|
|
|
3580
3580
|
|
|
3581
3581
|
// const MINIMUM_WAZO_ENGINE_VERSION_FOR_CTI_HOLD = '20.11';
|
|
3582
3582
|
|
|
3583
|
-
|
|
3583
|
+
IssueReporter$1 ? IssueReporter$1.loggerFor('cti-phone') : console;
|
|
3584
3584
|
|
|
3585
3585
|
/* */
|
|
3586
3586
|
|
|
@@ -4499,7 +4499,7 @@ const AGENTD_VERSION = '1.0';
|
|
|
4499
4499
|
const WEBHOOKD_VERSION = '1.0';
|
|
4500
4500
|
const AMID_VERSION = '1.0';
|
|
4501
4501
|
|
|
4502
|
-
const logger
|
|
4502
|
+
const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
4503
4503
|
|
|
4504
4504
|
class ApiClient {
|
|
4505
4505
|
|
|
@@ -4551,12 +4551,12 @@ class ApiClient {
|
|
|
4551
4551
|
}
|
|
4552
4552
|
|
|
4553
4553
|
async forceRefreshToken() {
|
|
4554
|
-
logger
|
|
4554
|
+
logger.info('forcing refresh token, calling callback');
|
|
4555
4555
|
return this.refreshTokenCallback();
|
|
4556
4556
|
}
|
|
4557
4557
|
|
|
4558
4558
|
async refreshTokenCallback() {
|
|
4559
|
-
logger
|
|
4559
|
+
logger.info('refresh token callback called', {
|
|
4560
4560
|
refreshToken: this.refreshToken,
|
|
4561
4561
|
refreshBackend: this.refreshBackend,
|
|
4562
4562
|
refreshExpiration: this.refreshExpiration,
|
|
@@ -4574,7 +4574,7 @@ class ApiClient {
|
|
|
4574
4574
|
this.isMobile,
|
|
4575
4575
|
);
|
|
4576
4576
|
|
|
4577
|
-
logger
|
|
4577
|
+
logger.info('token refreshed', { token: session.token });
|
|
4578
4578
|
|
|
4579
4579
|
if (this.onRefreshToken) {
|
|
4580
4580
|
this.onRefreshToken(session.token, session);
|