@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
|
@@ -446,11 +446,11 @@ var IssueReporter$1 = new IssueReporter();
|
|
|
446
446
|
|
|
447
447
|
const methods = ['head', 'get', 'post', 'put', 'delete'];
|
|
448
448
|
|
|
449
|
-
const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
449
|
+
const logger$1 = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
450
450
|
|
|
451
451
|
// Use a function here to be able to mock it in tests
|
|
452
452
|
const realFetch = () => {
|
|
453
|
-
if (typeof document !== 'undefined') {
|
|
453
|
+
if (typeof document !== 'undefined' && window.fetch) {
|
|
454
454
|
// Browser
|
|
455
455
|
return window.fetch;
|
|
456
456
|
}
|
|
@@ -585,7 +585,7 @@ class ApiRequester {
|
|
|
585
585
|
};
|
|
586
586
|
|
|
587
587
|
if (this.refreshTokenPromise) {
|
|
588
|
-
logger.info('A token is already refreshing, waiting ...', { url });
|
|
588
|
+
logger$1.info('A token is already refreshing, waiting ...', { url });
|
|
589
589
|
await this.refreshTokenPromise;
|
|
590
590
|
}
|
|
591
591
|
|
|
@@ -605,7 +605,7 @@ class ApiRequester {
|
|
|
605
605
|
return promise.then(async (err ) => {
|
|
606
606
|
// Check if the token is still valid
|
|
607
607
|
if (firstCall && this._checkTokenExpired(response, err)) {
|
|
608
|
-
logger.warn('token expired', { error: err.reason });
|
|
608
|
+
logger$1.warn('token expired', { error: err.reason });
|
|
609
609
|
// Replay the call after refreshing the token
|
|
610
610
|
return this._replayWithNewToken(err, path, method, body, headers, parse);
|
|
611
611
|
}
|
|
@@ -615,7 +615,7 @@ class ApiRequester {
|
|
|
615
615
|
: exceptionClass.fromResponse(err, response.status);
|
|
616
616
|
|
|
617
617
|
if (this.shouldLogErrors) {
|
|
618
|
-
logger.error('API error', error);
|
|
618
|
+
logger$1.error('API error', error);
|
|
619
619
|
}
|
|
620
620
|
|
|
621
621
|
throw error;
|
|
@@ -625,7 +625,7 @@ class ApiRequester {
|
|
|
625
625
|
return newParse(response, isJson);
|
|
626
626
|
}).catch(error => {
|
|
627
627
|
if (this.shouldLogErrors) {
|
|
628
|
-
logger.error('Fetch failed', { url, options, message: error.message, stack: error.stack });
|
|
628
|
+
logger$1.error('Fetch failed', { url, options, message: error.message, stack: error.stack });
|
|
629
629
|
}
|
|
630
630
|
|
|
631
631
|
throw error;
|
|
@@ -653,13 +653,13 @@ class ApiRequester {
|
|
|
653
653
|
) {
|
|
654
654
|
const isTokenNotFound = this._isTokenNotFound(err);
|
|
655
655
|
let newPath = path;
|
|
656
|
-
logger.info('refreshing token', { inProgress: !!this.refreshTokenPromise });
|
|
656
|
+
logger$1.info('refreshing token', { inProgress: !!this.refreshTokenPromise });
|
|
657
657
|
|
|
658
658
|
this.refreshTokenPromise = this.refreshTokenPromise || this.refreshTokenCallback();
|
|
659
659
|
|
|
660
660
|
return this.refreshTokenPromise.then(() => {
|
|
661
661
|
this.refreshTokenPromise = null;
|
|
662
|
-
logger.info('token refreshed', { isTokenNotFound });
|
|
662
|
+
logger$1.info('token refreshed', { isTokenNotFound });
|
|
663
663
|
if (isTokenNotFound) {
|
|
664
664
|
const pathParts = path.split('/');
|
|
665
665
|
pathParts.pop();
|
|
@@ -1910,7 +1910,7 @@ class Contact {
|
|
|
1910
1910
|
this[key] = old[key] || this[key];
|
|
1911
1911
|
});
|
|
1912
1912
|
|
|
1913
|
-
if (old.lineState
|
|
1913
|
+
if (old.lineState) {
|
|
1914
1914
|
this.lineState = old.lineState;
|
|
1915
1915
|
}
|
|
1916
1916
|
|
|
@@ -3601,7 +3601,7 @@ const TRANSFER_FLOW_BLIND = 'blind';
|
|
|
3601
3601
|
|
|
3602
3602
|
// const MINIMUM_WAZO_ENGINE_VERSION_FOR_CTI_HOLD = '20.11';
|
|
3603
3603
|
|
|
3604
|
-
|
|
3604
|
+
IssueReporter$1 ? IssueReporter$1.loggerFor('cti-phone') : console;
|
|
3605
3605
|
|
|
3606
3606
|
/* */
|
|
3607
3607
|
|
|
@@ -4520,7 +4520,7 @@ const AGENTD_VERSION = '1.0';
|
|
|
4520
4520
|
const WEBHOOKD_VERSION = '1.0';
|
|
4521
4521
|
const AMID_VERSION = '1.0';
|
|
4522
4522
|
|
|
4523
|
-
const logger
|
|
4523
|
+
const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
4524
4524
|
|
|
4525
4525
|
class ApiClient {
|
|
4526
4526
|
|
|
@@ -4572,12 +4572,12 @@ class ApiClient {
|
|
|
4572
4572
|
}
|
|
4573
4573
|
|
|
4574
4574
|
async forceRefreshToken() {
|
|
4575
|
-
logger
|
|
4575
|
+
logger.info('forcing refresh token, calling callback');
|
|
4576
4576
|
return this.refreshTokenCallback();
|
|
4577
4577
|
}
|
|
4578
4578
|
|
|
4579
4579
|
async refreshTokenCallback() {
|
|
4580
|
-
logger
|
|
4580
|
+
logger.info('refresh token callback called', {
|
|
4581
4581
|
refreshToken: this.refreshToken,
|
|
4582
4582
|
refreshBackend: this.refreshBackend,
|
|
4583
4583
|
refreshExpiration: this.refreshExpiration,
|
|
@@ -4595,7 +4595,7 @@ class ApiClient {
|
|
|
4595
4595
|
this.isMobile,
|
|
4596
4596
|
);
|
|
4597
4597
|
|
|
4598
|
-
logger
|
|
4598
|
+
logger.info('token refreshed', { token: session.token });
|
|
4599
4599
|
|
|
4600
4600
|
if (this.onRefreshToken) {
|
|
4601
4601
|
this.onRefreshToken(session.token, session);
|
|
@@ -446,11 +446,11 @@ var IssueReporter$1 = new IssueReporter();
|
|
|
446
446
|
|
|
447
447
|
const methods = ['head', 'get', 'post', 'put', 'delete'];
|
|
448
448
|
|
|
449
|
-
const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
449
|
+
const logger$1 = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
450
450
|
|
|
451
451
|
// Use a function here to be able to mock it in tests
|
|
452
452
|
const realFetch = () => {
|
|
453
|
-
if (typeof document !== 'undefined') {
|
|
453
|
+
if (typeof document !== 'undefined' && window.fetch) {
|
|
454
454
|
// Browser
|
|
455
455
|
return window.fetch;
|
|
456
456
|
}
|
|
@@ -585,7 +585,7 @@ class ApiRequester {
|
|
|
585
585
|
};
|
|
586
586
|
|
|
587
587
|
if (this.refreshTokenPromise) {
|
|
588
|
-
logger.info('A token is already refreshing, waiting ...', { url });
|
|
588
|
+
logger$1.info('A token is already refreshing, waiting ...', { url });
|
|
589
589
|
await this.refreshTokenPromise;
|
|
590
590
|
}
|
|
591
591
|
|
|
@@ -605,7 +605,7 @@ class ApiRequester {
|
|
|
605
605
|
return promise.then(async (err ) => {
|
|
606
606
|
// Check if the token is still valid
|
|
607
607
|
if (firstCall && this._checkTokenExpired(response, err)) {
|
|
608
|
-
logger.warn('token expired', { error: err.reason });
|
|
608
|
+
logger$1.warn('token expired', { error: err.reason });
|
|
609
609
|
// Replay the call after refreshing the token
|
|
610
610
|
return this._replayWithNewToken(err, path, method, body, headers, parse);
|
|
611
611
|
}
|
|
@@ -615,7 +615,7 @@ class ApiRequester {
|
|
|
615
615
|
: exceptionClass.fromResponse(err, response.status);
|
|
616
616
|
|
|
617
617
|
if (this.shouldLogErrors) {
|
|
618
|
-
logger.error('API error', error);
|
|
618
|
+
logger$1.error('API error', error);
|
|
619
619
|
}
|
|
620
620
|
|
|
621
621
|
throw error;
|
|
@@ -625,7 +625,7 @@ class ApiRequester {
|
|
|
625
625
|
return newParse(response, isJson);
|
|
626
626
|
}).catch(error => {
|
|
627
627
|
if (this.shouldLogErrors) {
|
|
628
|
-
logger.error('Fetch failed', { url, options, message: error.message, stack: error.stack });
|
|
628
|
+
logger$1.error('Fetch failed', { url, options, message: error.message, stack: error.stack });
|
|
629
629
|
}
|
|
630
630
|
|
|
631
631
|
throw error;
|
|
@@ -653,13 +653,13 @@ class ApiRequester {
|
|
|
653
653
|
) {
|
|
654
654
|
const isTokenNotFound = this._isTokenNotFound(err);
|
|
655
655
|
let newPath = path;
|
|
656
|
-
logger.info('refreshing token', { inProgress: !!this.refreshTokenPromise });
|
|
656
|
+
logger$1.info('refreshing token', { inProgress: !!this.refreshTokenPromise });
|
|
657
657
|
|
|
658
658
|
this.refreshTokenPromise = this.refreshTokenPromise || this.refreshTokenCallback();
|
|
659
659
|
|
|
660
660
|
return this.refreshTokenPromise.then(() => {
|
|
661
661
|
this.refreshTokenPromise = null;
|
|
662
|
-
logger.info('token refreshed', { isTokenNotFound });
|
|
662
|
+
logger$1.info('token refreshed', { isTokenNotFound });
|
|
663
663
|
if (isTokenNotFound) {
|
|
664
664
|
const pathParts = path.split('/');
|
|
665
665
|
pathParts.pop();
|
|
@@ -1910,7 +1910,7 @@ class Contact {
|
|
|
1910
1910
|
this[key] = old[key] || this[key];
|
|
1911
1911
|
});
|
|
1912
1912
|
|
|
1913
|
-
if (old.lineState
|
|
1913
|
+
if (old.lineState) {
|
|
1914
1914
|
this.lineState = old.lineState;
|
|
1915
1915
|
}
|
|
1916
1916
|
|
|
@@ -3601,7 +3601,7 @@ const TRANSFER_FLOW_BLIND = 'blind';
|
|
|
3601
3601
|
|
|
3602
3602
|
// const MINIMUM_WAZO_ENGINE_VERSION_FOR_CTI_HOLD = '20.11';
|
|
3603
3603
|
|
|
3604
|
-
|
|
3604
|
+
IssueReporter$1 ? IssueReporter$1.loggerFor('cti-phone') : console;
|
|
3605
3605
|
|
|
3606
3606
|
/* */
|
|
3607
3607
|
|
|
@@ -4520,7 +4520,7 @@ const AGENTD_VERSION = '1.0';
|
|
|
4520
4520
|
const WEBHOOKD_VERSION = '1.0';
|
|
4521
4521
|
const AMID_VERSION = '1.0';
|
|
4522
4522
|
|
|
4523
|
-
const logger
|
|
4523
|
+
const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
4524
4524
|
|
|
4525
4525
|
class ApiClient {
|
|
4526
4526
|
|
|
@@ -4572,12 +4572,12 @@ class ApiClient {
|
|
|
4572
4572
|
}
|
|
4573
4573
|
|
|
4574
4574
|
async forceRefreshToken() {
|
|
4575
|
-
logger
|
|
4575
|
+
logger.info('forcing refresh token, calling callback');
|
|
4576
4576
|
return this.refreshTokenCallback();
|
|
4577
4577
|
}
|
|
4578
4578
|
|
|
4579
4579
|
async refreshTokenCallback() {
|
|
4580
|
-
logger
|
|
4580
|
+
logger.info('refresh token callback called', {
|
|
4581
4581
|
refreshToken: this.refreshToken,
|
|
4582
4582
|
refreshBackend: this.refreshBackend,
|
|
4583
4583
|
refreshExpiration: this.refreshExpiration,
|
|
@@ -4595,7 +4595,7 @@ class ApiClient {
|
|
|
4595
4595
|
this.isMobile,
|
|
4596
4596
|
);
|
|
4597
4597
|
|
|
4598
|
-
logger
|
|
4598
|
+
logger.info('token refreshed', { token: session.token });
|
|
4599
4599
|
|
|
4600
4600
|
if (this.onRefreshToken) {
|
|
4601
4601
|
this.onRefreshToken(session.token, session);
|