@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
|
@@ -21,11 +21,11 @@ const isMobile = () => typeof navigator !== 'undefined' && navigator.product ===
|
|
|
21
21
|
|
|
22
22
|
/* */
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
25
25
|
|
|
26
26
|
// Use a function here to be able to mock it in tests
|
|
27
27
|
const realFetch = () => {
|
|
28
|
-
if (typeof document !== 'undefined') {
|
|
28
|
+
if (typeof document !== 'undefined' && window.fetch) {
|
|
29
29
|
// Browser
|
|
30
30
|
return window.fetch;
|
|
31
31
|
}
|
|
@@ -497,11 +497,16 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
|
|
|
497
497
|
|
|
498
498
|
// $FlowFixMe
|
|
499
499
|
setRemoteSessionDescription(sessionDescription ) {
|
|
500
|
-
|
|
500
|
+
try {
|
|
501
|
+
const result = super.setRemoteSessionDescription(sessionDescription);
|
|
501
502
|
|
|
502
|
-
|
|
503
|
+
this.eventEmitter.emit('setDescription', sessionDescription);
|
|
503
504
|
|
|
504
|
-
|
|
505
|
+
return result;
|
|
506
|
+
} catch (error) {
|
|
507
|
+
this.logger.error('SessionDescriptionHandler.setRemoteSessionDescription error', error);
|
|
508
|
+
throw error;
|
|
509
|
+
}
|
|
505
510
|
}
|
|
506
511
|
|
|
507
512
|
// Overridden to avoid to fix ice-candidates missing in the SDP in react-native and chrome canary.
|
package/lib/service/CallApi.js
CHANGED
|
@@ -1416,7 +1416,7 @@ class Contact {
|
|
|
1416
1416
|
this[key] = old[key] || this[key];
|
|
1417
1417
|
});
|
|
1418
1418
|
|
|
1419
|
-
if (old.lineState
|
|
1419
|
+
if (old.lineState) {
|
|
1420
1420
|
this.lineState = old.lineState;
|
|
1421
1421
|
}
|
|
1422
1422
|
|
|
@@ -2468,11 +2468,11 @@ var IssueReporter$1 = new IssueReporter();
|
|
|
2468
2468
|
|
|
2469
2469
|
const methods = ['head', 'get', 'post', 'put', 'delete'];
|
|
2470
2470
|
|
|
2471
|
-
const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
2471
|
+
const logger$1 = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
2472
2472
|
|
|
2473
2473
|
// Use a function here to be able to mock it in tests
|
|
2474
2474
|
const realFetch = () => {
|
|
2475
|
-
if (typeof document !== 'undefined') {
|
|
2475
|
+
if (typeof document !== 'undefined' && window.fetch) {
|
|
2476
2476
|
// Browser
|
|
2477
2477
|
return window.fetch;
|
|
2478
2478
|
}
|
|
@@ -2607,7 +2607,7 @@ class ApiRequester {
|
|
|
2607
2607
|
};
|
|
2608
2608
|
|
|
2609
2609
|
if (this.refreshTokenPromise) {
|
|
2610
|
-
logger.info('A token is already refreshing, waiting ...', { url });
|
|
2610
|
+
logger$1.info('A token is already refreshing, waiting ...', { url });
|
|
2611
2611
|
await this.refreshTokenPromise;
|
|
2612
2612
|
}
|
|
2613
2613
|
|
|
@@ -2627,7 +2627,7 @@ class ApiRequester {
|
|
|
2627
2627
|
return promise.then(async (err ) => {
|
|
2628
2628
|
// Check if the token is still valid
|
|
2629
2629
|
if (firstCall && this._checkTokenExpired(response, err)) {
|
|
2630
|
-
logger.warn('token expired', { error: err.reason });
|
|
2630
|
+
logger$1.warn('token expired', { error: err.reason });
|
|
2631
2631
|
// Replay the call after refreshing the token
|
|
2632
2632
|
return this._replayWithNewToken(err, path, method, body, headers, parse);
|
|
2633
2633
|
}
|
|
@@ -2637,7 +2637,7 @@ class ApiRequester {
|
|
|
2637
2637
|
: exceptionClass.fromResponse(err, response.status);
|
|
2638
2638
|
|
|
2639
2639
|
if (this.shouldLogErrors) {
|
|
2640
|
-
logger.error('API error', error);
|
|
2640
|
+
logger$1.error('API error', error);
|
|
2641
2641
|
}
|
|
2642
2642
|
|
|
2643
2643
|
throw error;
|
|
@@ -2647,7 +2647,7 @@ class ApiRequester {
|
|
|
2647
2647
|
return newParse(response, isJson);
|
|
2648
2648
|
}).catch(error => {
|
|
2649
2649
|
if (this.shouldLogErrors) {
|
|
2650
|
-
logger.error('Fetch failed', { url, options, message: error.message, stack: error.stack });
|
|
2650
|
+
logger$1.error('Fetch failed', { url, options, message: error.message, stack: error.stack });
|
|
2651
2651
|
}
|
|
2652
2652
|
|
|
2653
2653
|
throw error;
|
|
@@ -2675,13 +2675,13 @@ class ApiRequester {
|
|
|
2675
2675
|
) {
|
|
2676
2676
|
const isTokenNotFound = this._isTokenNotFound(err);
|
|
2677
2677
|
let newPath = path;
|
|
2678
|
-
logger.info('refreshing token', { inProgress: !!this.refreshTokenPromise });
|
|
2678
|
+
logger$1.info('refreshing token', { inProgress: !!this.refreshTokenPromise });
|
|
2679
2679
|
|
|
2680
2680
|
this.refreshTokenPromise = this.refreshTokenPromise || this.refreshTokenCallback();
|
|
2681
2681
|
|
|
2682
2682
|
return this.refreshTokenPromise.then(() => {
|
|
2683
2683
|
this.refreshTokenPromise = null;
|
|
2684
|
-
logger.info('token refreshed', { isTokenNotFound });
|
|
2684
|
+
logger$1.info('token refreshed', { isTokenNotFound });
|
|
2685
2685
|
if (isTokenNotFound) {
|
|
2686
2686
|
const pathParts = path.split('/');
|
|
2687
2687
|
pathParts.pop();
|
|
@@ -3518,7 +3518,7 @@ const TRANSFER_FLOW_BLIND = 'blind';
|
|
|
3518
3518
|
|
|
3519
3519
|
// const MINIMUM_WAZO_ENGINE_VERSION_FOR_CTI_HOLD = '20.11';
|
|
3520
3520
|
|
|
3521
|
-
|
|
3521
|
+
IssueReporter$1 ? IssueReporter$1.loggerFor('cti-phone') : console;
|
|
3522
3522
|
|
|
3523
3523
|
/* */
|
|
3524
3524
|
|
|
@@ -4505,7 +4505,7 @@ const AGENTD_VERSION = '1.0';
|
|
|
4505
4505
|
const WEBHOOKD_VERSION = '1.0';
|
|
4506
4506
|
const AMID_VERSION = '1.0';
|
|
4507
4507
|
|
|
4508
|
-
const logger
|
|
4508
|
+
const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
4509
4509
|
|
|
4510
4510
|
class ApiClient {
|
|
4511
4511
|
|
|
@@ -4557,12 +4557,12 @@ class ApiClient {
|
|
|
4557
4557
|
}
|
|
4558
4558
|
|
|
4559
4559
|
async forceRefreshToken() {
|
|
4560
|
-
logger
|
|
4560
|
+
logger.info('forcing refresh token, calling callback');
|
|
4561
4561
|
return this.refreshTokenCallback();
|
|
4562
4562
|
}
|
|
4563
4563
|
|
|
4564
4564
|
async refreshTokenCallback() {
|
|
4565
|
-
logger
|
|
4565
|
+
logger.info('refresh token callback called', {
|
|
4566
4566
|
refreshToken: this.refreshToken,
|
|
4567
4567
|
refreshBackend: this.refreshBackend,
|
|
4568
4568
|
refreshExpiration: this.refreshExpiration,
|
|
@@ -4580,7 +4580,7 @@ class ApiClient {
|
|
|
4580
4580
|
this.isMobile,
|
|
4581
4581
|
);
|
|
4582
4582
|
|
|
4583
|
-
logger
|
|
4583
|
+
logger.info('token refreshed', { token: session.token });
|
|
4584
4584
|
|
|
4585
4585
|
if (this.onRefreshToken) {
|
|
4586
4586
|
this.onRefreshToken(session.token, session);
|
|
@@ -13,11 +13,11 @@ const isMobile = () => typeof navigator !== 'undefined' && navigator.product ===
|
|
|
13
13
|
|
|
14
14
|
/* */
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
17
17
|
|
|
18
18
|
// Use a function here to be able to mock it in tests
|
|
19
19
|
const realFetch = () => {
|
|
20
|
-
if (typeof document !== 'undefined') {
|
|
20
|
+
if (typeof document !== 'undefined' && window.fetch) {
|
|
21
21
|
// Browser
|
|
22
22
|
return window.fetch;
|
|
23
23
|
}
|
|
@@ -13,11 +13,11 @@ const isMobile = () => typeof navigator !== 'undefined' && navigator.product ===
|
|
|
13
13
|
|
|
14
14
|
/* */
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
17
17
|
|
|
18
18
|
// Use a function here to be able to mock it in tests
|
|
19
19
|
const realFetch = () => {
|
|
20
|
-
if (typeof document !== 'undefined') {
|
|
20
|
+
if (typeof document !== 'undefined' && window.fetch) {
|
|
21
21
|
// Browser
|
|
22
22
|
return window.fetch;
|
|
23
23
|
}
|
|
@@ -448,11 +448,11 @@ var IssueReporter$1 = new IssueReporter();
|
|
|
448
448
|
|
|
449
449
|
const methods = ['head', 'get', 'post', 'put', 'delete'];
|
|
450
450
|
|
|
451
|
-
const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
451
|
+
const logger$1 = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
452
452
|
|
|
453
453
|
// Use a function here to be able to mock it in tests
|
|
454
454
|
const realFetch = () => {
|
|
455
|
-
if (typeof document !== 'undefined') {
|
|
455
|
+
if (typeof document !== 'undefined' && window.fetch) {
|
|
456
456
|
// Browser
|
|
457
457
|
return window.fetch;
|
|
458
458
|
}
|
|
@@ -587,7 +587,7 @@ class ApiRequester {
|
|
|
587
587
|
};
|
|
588
588
|
|
|
589
589
|
if (this.refreshTokenPromise) {
|
|
590
|
-
logger.info('A token is already refreshing, waiting ...', { url });
|
|
590
|
+
logger$1.info('A token is already refreshing, waiting ...', { url });
|
|
591
591
|
await this.refreshTokenPromise;
|
|
592
592
|
}
|
|
593
593
|
|
|
@@ -607,7 +607,7 @@ class ApiRequester {
|
|
|
607
607
|
return promise.then(async (err ) => {
|
|
608
608
|
// Check if the token is still valid
|
|
609
609
|
if (firstCall && this._checkTokenExpired(response, err)) {
|
|
610
|
-
logger.warn('token expired', { error: err.reason });
|
|
610
|
+
logger$1.warn('token expired', { error: err.reason });
|
|
611
611
|
// Replay the call after refreshing the token
|
|
612
612
|
return this._replayWithNewToken(err, path, method, body, headers, parse);
|
|
613
613
|
}
|
|
@@ -617,7 +617,7 @@ class ApiRequester {
|
|
|
617
617
|
: exceptionClass.fromResponse(err, response.status);
|
|
618
618
|
|
|
619
619
|
if (this.shouldLogErrors) {
|
|
620
|
-
logger.error('API error', error);
|
|
620
|
+
logger$1.error('API error', error);
|
|
621
621
|
}
|
|
622
622
|
|
|
623
623
|
throw error;
|
|
@@ -627,7 +627,7 @@ class ApiRequester {
|
|
|
627
627
|
return newParse(response, isJson);
|
|
628
628
|
}).catch(error => {
|
|
629
629
|
if (this.shouldLogErrors) {
|
|
630
|
-
logger.error('Fetch failed', { url, options, message: error.message, stack: error.stack });
|
|
630
|
+
logger$1.error('Fetch failed', { url, options, message: error.message, stack: error.stack });
|
|
631
631
|
}
|
|
632
632
|
|
|
633
633
|
throw error;
|
|
@@ -655,13 +655,13 @@ class ApiRequester {
|
|
|
655
655
|
) {
|
|
656
656
|
const isTokenNotFound = this._isTokenNotFound(err);
|
|
657
657
|
let newPath = path;
|
|
658
|
-
logger.info('refreshing token', { inProgress: !!this.refreshTokenPromise });
|
|
658
|
+
logger$1.info('refreshing token', { inProgress: !!this.refreshTokenPromise });
|
|
659
659
|
|
|
660
660
|
this.refreshTokenPromise = this.refreshTokenPromise || this.refreshTokenCallback();
|
|
661
661
|
|
|
662
662
|
return this.refreshTokenPromise.then(() => {
|
|
663
663
|
this.refreshTokenPromise = null;
|
|
664
|
-
logger.info('token refreshed', { isTokenNotFound });
|
|
664
|
+
logger$1.info('token refreshed', { isTokenNotFound });
|
|
665
665
|
if (isTokenNotFound) {
|
|
666
666
|
const pathParts = path.split('/');
|
|
667
667
|
pathParts.pop();
|
|
@@ -1912,7 +1912,7 @@ class Contact {
|
|
|
1912
1912
|
this[key] = old[key] || this[key];
|
|
1913
1913
|
});
|
|
1914
1914
|
|
|
1915
|
-
if (old.lineState
|
|
1915
|
+
if (old.lineState) {
|
|
1916
1916
|
this.lineState = old.lineState;
|
|
1917
1917
|
}
|
|
1918
1918
|
|
|
@@ -3588,7 +3588,7 @@ const TRANSFER_FLOW_BLIND = 'blind';
|
|
|
3588
3588
|
|
|
3589
3589
|
// const MINIMUM_WAZO_ENGINE_VERSION_FOR_CTI_HOLD = '20.11';
|
|
3590
3590
|
|
|
3591
|
-
|
|
3591
|
+
IssueReporter$1 ? IssueReporter$1.loggerFor('cti-phone') : console;
|
|
3592
3592
|
|
|
3593
3593
|
/* */
|
|
3594
3594
|
|
|
@@ -4507,7 +4507,7 @@ const AGENTD_VERSION = '1.0';
|
|
|
4507
4507
|
const WEBHOOKD_VERSION = '1.0';
|
|
4508
4508
|
const AMID_VERSION = '1.0';
|
|
4509
4509
|
|
|
4510
|
-
const logger
|
|
4510
|
+
const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
4511
4511
|
|
|
4512
4512
|
class ApiClient {
|
|
4513
4513
|
|
|
@@ -4559,12 +4559,12 @@ class ApiClient {
|
|
|
4559
4559
|
}
|
|
4560
4560
|
|
|
4561
4561
|
async forceRefreshToken() {
|
|
4562
|
-
logger
|
|
4562
|
+
logger.info('forcing refresh token, calling callback');
|
|
4563
4563
|
return this.refreshTokenCallback();
|
|
4564
4564
|
}
|
|
4565
4565
|
|
|
4566
4566
|
async refreshTokenCallback() {
|
|
4567
|
-
logger
|
|
4567
|
+
logger.info('refresh token callback called', {
|
|
4568
4568
|
refreshToken: this.refreshToken,
|
|
4569
4569
|
refreshBackend: this.refreshBackend,
|
|
4570
4570
|
refreshExpiration: this.refreshExpiration,
|
|
@@ -4582,7 +4582,7 @@ class ApiClient {
|
|
|
4582
4582
|
this.isMobile,
|
|
4583
4583
|
);
|
|
4584
4584
|
|
|
4585
|
-
logger
|
|
4585
|
+
logger.info('token refreshed', { token: session.token });
|
|
4586
4586
|
|
|
4587
4587
|
if (this.onRefreshToken) {
|
|
4588
4588
|
this.onRefreshToken(session.token, session);
|