@wazo/sdk 0.37.41 → 0.38.0
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 +45 -22
- package/esm/__tests__/web-rtc-client.test.js +49 -24
- package/esm/api/agentd.js +12 -7
- package/esm/api/amid.js +12 -7
- package/esm/api/application.js +12 -7
- package/esm/api/auth.js +16 -8
- package/esm/api/call-logd.js +12 -7
- package/esm/api/calld.js +12 -7
- package/esm/api/chatd.js +12 -7
- package/esm/api/confd.js +12 -7
- package/esm/api/ctid-ng.js +14 -7
- package/esm/api/dird.js +12 -7
- package/esm/api/webhookd.js +12 -7
- package/esm/api-client.js +45 -22
- package/esm/checker/Checker.js +50 -25
- package/esm/checker/checks/aor.js +45 -22
- package/esm/checker/checks/api.js +45 -22
- package/esm/checker/checks/index.js +50 -25
- package/esm/checker/checks/wazo-websocket.js +13 -8
- package/esm/checker/checks/webrtc-transport.js +49 -24
- package/esm/checker/checks/webrtc.js +49 -24
- package/esm/domain/AdHocAPIConference.js +54 -23
- package/esm/domain/Features.js +54 -23
- package/esm/domain/Phone/CTIPhone.js +54 -23
- package/esm/domain/Phone/WebRTCPhone.js +14 -7
- package/esm/index.js +233 -25
- package/esm/lib/WazoSessionDescriptionHandler.js +12 -7
- package/esm/service/CallApi.js +54 -23
- package/esm/service/IssueReporter.js +12 -7
- package/esm/service/__tests__/IssueReporter.test.js +18 -7
- package/esm/service/getApiClient.js +63 -24
- package/esm/simple/Auth.js +233 -25
- package/esm/simple/Configuration.js +233 -25
- package/esm/simple/Directory.js +54 -23
- package/esm/simple/Phone.js +233 -25
- package/esm/simple/Softphone.js +148 -0
- package/esm/simple/Websocket.js +13 -8
- package/esm/simple/index.js +233 -25
- package/esm/simple/room/LocalParticipant.js +233 -25
- package/esm/simple/room/Participant.js +233 -25
- package/esm/simple/room/RemoteParticipant.js +233 -25
- package/esm/simple/room/Room.js +233 -25
- package/esm/simple/room/SipRoom.js +233 -25
- package/esm/simple/room/Stream.js +233 -25
- package/esm/simple/room/__tests__/RemoteParticipant.test.js +233 -25
- package/esm/simple/utils.js +233 -25
- package/esm/utils/__tests__/api-requester.test.js +12 -7
- package/esm/utils/api-requester.js +12 -7
- package/esm/web-rtc-client.js +49 -24
- package/esm/websocket-client.js +13 -8
- package/lib/__tests__/api-client.test.js +45 -22
- package/lib/__tests__/web-rtc-client.test.js +49 -24
- package/lib/api/agentd.js +12 -7
- package/lib/api/amid.js +12 -7
- package/lib/api/application.js +12 -7
- package/lib/api/auth.js +16 -8
- package/lib/api/call-logd.js +12 -7
- package/lib/api/calld.js +12 -7
- package/lib/api/chatd.js +12 -7
- package/lib/api/confd.js +12 -7
- package/lib/api/ctid-ng.js +14 -7
- package/lib/api/dird.js +12 -7
- package/lib/api/webhookd.js +12 -7
- package/lib/api-client.js +45 -22
- package/lib/checker/Checker.js +50 -25
- package/lib/checker/checks/aor.js +45 -22
- package/lib/checker/checks/api.js +45 -22
- package/lib/checker/checks/index.js +50 -25
- package/lib/checker/checks/wazo-websocket.js +13 -8
- package/lib/checker/checks/webrtc-transport.js +49 -24
- package/lib/checker/checks/webrtc.js +49 -24
- package/lib/domain/AdHocAPIConference.js +54 -23
- package/lib/domain/Features.js +54 -23
- package/lib/domain/Phone/CTIPhone.js +54 -23
- package/lib/domain/Phone/WebRTCPhone.js +14 -7
- package/lib/index.js +233 -25
- package/lib/lib/WazoSessionDescriptionHandler.js +12 -7
- package/lib/service/CallApi.js +54 -23
- package/lib/service/IssueReporter.js +12 -7
- package/lib/service/__tests__/IssueReporter.test.js +18 -7
- package/lib/service/getApiClient.js +64 -23
- package/lib/simple/Auth.js +233 -25
- package/lib/simple/Configuration.js +233 -25
- package/lib/simple/Directory.js +54 -23
- package/lib/simple/Phone.js +233 -25
- package/lib/simple/Softphone.js +150 -0
- package/lib/simple/Websocket.js +13 -8
- package/lib/simple/index.js +233 -25
- package/lib/simple/room/LocalParticipant.js +233 -25
- package/lib/simple/room/Participant.js +233 -25
- package/lib/simple/room/RemoteParticipant.js +233 -25
- package/lib/simple/room/Room.js +233 -25
- package/lib/simple/room/SipRoom.js +233 -25
- package/lib/simple/room/Stream.js +233 -25
- package/lib/simple/room/__tests__/RemoteParticipant.test.js +233 -25
- package/lib/simple/utils.js +233 -25
- package/lib/utils/__tests__/api-requester.test.js +12 -7
- package/lib/utils/api-requester.js +12 -7
- package/lib/web-rtc-client.js +49 -24
- package/lib/websocket-client.js +13 -8
- package/package.json +1 -1
- package/src/api/auth.js +4 -1
- package/src/api-client.js +26 -13
- package/src/service/IssueReporter.js +12 -7
- package/src/service/__tests__/IssueReporter.test.js +6 -0
- package/src/service/getApiClient.js +19 -1
- package/src/simple/Auth.js +21 -0
- package/src/simple/Softphone.js +148 -0
- package/src/simple/index.js +2 -0
- package/src/web-rtc-client.js +4 -2
- package/src/websocket-client.js +1 -1
package/esm/service/CallApi.js
CHANGED
|
@@ -2430,13 +2430,9 @@ class IssueReporter {
|
|
|
2430
2430
|
|
|
2431
2431
|
setTimeout(() => {
|
|
2432
2432
|
if (isArray) {
|
|
2433
|
-
payload = payload.map(message =>
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
});
|
|
2437
|
-
} else {
|
|
2438
|
-
// $FlowFixMe
|
|
2439
|
-
payload._retry = retry + 1;
|
|
2433
|
+
payload = payload.map(message => this._writeRetryCount(message, retry + 1));
|
|
2434
|
+
} else if (payload && typeof payload === 'object') {
|
|
2435
|
+
payload = this._writeRetryCount(payload, retry + 1);
|
|
2440
2436
|
}
|
|
2441
2437
|
|
|
2442
2438
|
this._sendDebugToGrafana(payload, retry + 1);
|
|
@@ -2444,6 +2440,15 @@ class IssueReporter {
|
|
|
2444
2440
|
});
|
|
2445
2441
|
}
|
|
2446
2442
|
|
|
2443
|
+
_writeRetryCount(message , count ) {
|
|
2444
|
+
if (message && typeof message === 'object') {
|
|
2445
|
+
// $FlowFixMe
|
|
2446
|
+
message._retry = count;
|
|
2447
|
+
}
|
|
2448
|
+
|
|
2449
|
+
return message;
|
|
2450
|
+
}
|
|
2451
|
+
|
|
2447
2452
|
_isLevelAbove(level1 , level2 ) {
|
|
2448
2453
|
const index1 = LOG_LEVELS.indexOf(level1);
|
|
2449
2454
|
const index2 = LOG_LEVELS.indexOf(level2);
|
|
@@ -2785,9 +2790,12 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2785
2790
|
expiration: expiration || DETAULT_EXPIRATION,
|
|
2786
2791
|
refresh_token: refreshToken,
|
|
2787
2792
|
client_id: client.clientId,
|
|
2788
|
-
tenant_id: tenantId,
|
|
2789
2793
|
};
|
|
2790
2794
|
|
|
2795
|
+
if (tenantId) {
|
|
2796
|
+
body.tenant_id = tenantId;
|
|
2797
|
+
}
|
|
2798
|
+
|
|
2791
2799
|
const headers = {
|
|
2792
2800
|
'Content-Type': 'application/json',
|
|
2793
2801
|
...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),
|
|
@@ -4566,6 +4574,7 @@ class ApiClient {
|
|
|
4566
4574
|
|
|
4567
4575
|
|
|
4568
4576
|
|
|
4577
|
+
|
|
4569
4578
|
|
|
4570
4579
|
|
|
4571
4580
|
|
|
@@ -4618,23 +4627,31 @@ class ApiClient {
|
|
|
4618
4627
|
return null;
|
|
4619
4628
|
}
|
|
4620
4629
|
|
|
4621
|
-
|
|
4622
|
-
this.refreshToken
|
|
4623
|
-
|
|
4624
|
-
|
|
4625
|
-
|
|
4626
|
-
|
|
4627
|
-
|
|
4628
|
-
|
|
4629
|
-
|
|
4630
|
+
try {
|
|
4631
|
+
const session = await this.auth.refreshToken(
|
|
4632
|
+
this.refreshToken,
|
|
4633
|
+
this.refreshBackend,
|
|
4634
|
+
this.refreshExpiration,
|
|
4635
|
+
this.isMobile,
|
|
4636
|
+
this.refreshTenantId,
|
|
4637
|
+
);
|
|
4638
|
+
|
|
4639
|
+
logger.info('token refreshed', { token: session.token });
|
|
4640
|
+
|
|
4641
|
+
if (this.onRefreshToken) {
|
|
4642
|
+
this.onRefreshToken(session.token, session);
|
|
4643
|
+
}
|
|
4630
4644
|
|
|
4631
|
-
|
|
4632
|
-
this.onRefreshToken(session.token, session);
|
|
4633
|
-
}
|
|
4645
|
+
this.setToken(session.token);
|
|
4634
4646
|
|
|
4635
|
-
|
|
4647
|
+
return session.token;
|
|
4648
|
+
} catch (error) {
|
|
4649
|
+
logger.error('token refresh, error', error);
|
|
4636
4650
|
|
|
4637
|
-
|
|
4651
|
+
if (this.onRefreshTokenError) {
|
|
4652
|
+
this.onRefreshTokenError(error);
|
|
4653
|
+
}
|
|
4654
|
+
}
|
|
4638
4655
|
}
|
|
4639
4656
|
|
|
4640
4657
|
setToken(token ) {
|
|
@@ -4657,6 +4674,10 @@ class ApiClient {
|
|
|
4657
4674
|
this.onRefreshToken = onRefreshToken;
|
|
4658
4675
|
}
|
|
4659
4676
|
|
|
4677
|
+
setOnRefreshTokenError(callback ) {
|
|
4678
|
+
this.onRefreshTokenError = callback;
|
|
4679
|
+
}
|
|
4680
|
+
|
|
4660
4681
|
setRefreshExpiration(refreshExpiration ) {
|
|
4661
4682
|
this.refreshExpiration = refreshExpiration;
|
|
4662
4683
|
}
|
|
@@ -4692,7 +4713,9 @@ global.wazoClients = global.wazoClients || {};
|
|
|
4692
4713
|
global.wazoClientId = global.wazoClientId || {};
|
|
4693
4714
|
global.wazoClientToken = global.wazoClientToken || {};
|
|
4694
4715
|
global.wazoRefreshToken = global.wazoRefreshToken || {};
|
|
4716
|
+
global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
|
|
4695
4717
|
global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
|
|
4718
|
+
global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
|
|
4696
4719
|
global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
|
|
4697
4720
|
global.wazoRefreshBackend = global.wazoRefreshBackend || {};
|
|
4698
4721
|
global.wazoIsMobile = global.wazoIsMobile || {};
|
|
@@ -4708,12 +4731,20 @@ const fillClient = (apiClient ) => {
|
|
|
4708
4731
|
|
|
4709
4732
|
apiClient.setRefreshToken(global.wazoRefreshToken[server] || global.wazoRefreshToken[null] || apiClient.refreshToken);
|
|
4710
4733
|
|
|
4734
|
+
apiClient.setRefreshTenantId(
|
|
4735
|
+
global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId,
|
|
4736
|
+
);
|
|
4737
|
+
|
|
4711
4738
|
apiClient.setFetchOptions(global.wazoFetchOptions[server] || global.wazoFetchOptions[null] || apiClient.fetchOptions);
|
|
4712
4739
|
|
|
4713
4740
|
apiClient.setOnRefreshToken(
|
|
4714
4741
|
global.wazoOnRefreshToken[server] || global.wazoOnRefreshToken[null] || apiClient.onRefreshToken,
|
|
4715
4742
|
);
|
|
4716
4743
|
|
|
4744
|
+
apiClient.setOnRefreshTokenError(
|
|
4745
|
+
global.wazoOnRefreshTokenError[server] || global.wazoOnRefreshTokenError[null] || apiClient.onRefreshTokenError,
|
|
4746
|
+
);
|
|
4747
|
+
|
|
4717
4748
|
apiClient.setRefreshExpiration(
|
|
4718
4749
|
global.wazoRefreshExpiration[server] || global.wazoRefreshExpiration[null] || apiClient.refreshExpiration,
|
|
4719
4750
|
);
|
|
@@ -4727,7 +4758,7 @@ const fillClient = (apiClient ) => {
|
|
|
4727
4758
|
return apiClient;
|
|
4728
4759
|
};
|
|
4729
4760
|
|
|
4730
|
-
var getApiClient = (forServer
|
|
4761
|
+
var getApiClient = (forServer = null) => {
|
|
4731
4762
|
const server = forServer || global.wazoCurrentServer || '';
|
|
4732
4763
|
if (server in global.wazoClients) {
|
|
4733
4764
|
return fillClient(global.wazoClients[server]);
|
|
@@ -359,13 +359,9 @@ class IssueReporter {
|
|
|
359
359
|
|
|
360
360
|
setTimeout(() => {
|
|
361
361
|
if (isArray) {
|
|
362
|
-
payload = payload.map(message =>
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
});
|
|
366
|
-
} else {
|
|
367
|
-
// $FlowFixMe
|
|
368
|
-
payload._retry = retry + 1;
|
|
362
|
+
payload = payload.map(message => this._writeRetryCount(message, retry + 1));
|
|
363
|
+
} else if (payload && typeof payload === 'object') {
|
|
364
|
+
payload = this._writeRetryCount(payload, retry + 1);
|
|
369
365
|
}
|
|
370
366
|
|
|
371
367
|
this._sendDebugToGrafana(payload, retry + 1);
|
|
@@ -373,6 +369,15 @@ class IssueReporter {
|
|
|
373
369
|
});
|
|
374
370
|
}
|
|
375
371
|
|
|
372
|
+
_writeRetryCount(message , count ) {
|
|
373
|
+
if (message && typeof message === 'object') {
|
|
374
|
+
// $FlowFixMe
|
|
375
|
+
message._retry = count;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
return message;
|
|
379
|
+
}
|
|
380
|
+
|
|
376
381
|
_isLevelAbove(level1 , level2 ) {
|
|
377
382
|
const index1 = LOG_LEVELS.indexOf(level1);
|
|
378
383
|
const index2 = LOG_LEVELS.indexOf(level2);
|
|
@@ -359,13 +359,9 @@ class IssueReporter {
|
|
|
359
359
|
|
|
360
360
|
setTimeout(() => {
|
|
361
361
|
if (isArray) {
|
|
362
|
-
payload = payload.map(message =>
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
});
|
|
366
|
-
} else {
|
|
367
|
-
// $FlowFixMe
|
|
368
|
-
payload._retry = retry + 1;
|
|
362
|
+
payload = payload.map(message => this._writeRetryCount(message, retry + 1));
|
|
363
|
+
} else if (payload && typeof payload === 'object') {
|
|
364
|
+
payload = this._writeRetryCount(payload, retry + 1);
|
|
369
365
|
}
|
|
370
366
|
|
|
371
367
|
this._sendDebugToGrafana(payload, retry + 1);
|
|
@@ -373,6 +369,15 @@ class IssueReporter {
|
|
|
373
369
|
});
|
|
374
370
|
}
|
|
375
371
|
|
|
372
|
+
_writeRetryCount(message , count ) {
|
|
373
|
+
if (message && typeof message === 'object') {
|
|
374
|
+
// $FlowFixMe
|
|
375
|
+
message._retry = count;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
return message;
|
|
379
|
+
}
|
|
380
|
+
|
|
376
381
|
_isLevelAbove(level1 , level2 ) {
|
|
377
382
|
const index1 = LOG_LEVELS.indexOf(level1);
|
|
378
383
|
const index2 = LOG_LEVELS.indexOf(level2);
|
|
@@ -488,4 +493,10 @@ describe('IssueReporter', () => {
|
|
|
488
493
|
expect(IssueReporter$1.removeSlashes('\"')).toBe("'");
|
|
489
494
|
expect(IssueReporter$1.removeSlashes('\\\"')).toBe("'");
|
|
490
495
|
});
|
|
496
|
+
|
|
497
|
+
it('Add retry count', () => {
|
|
498
|
+
expect(IssueReporter$1._writeRetryCount('', 1)).toBe('');
|
|
499
|
+
expect(IssueReporter$1._writeRetryCount('{}', 1)).toBe('{}');
|
|
500
|
+
expect(IssueReporter$1._writeRetryCount({}, 1)).toEqual({ _retry: 1 });
|
|
501
|
+
});
|
|
491
502
|
});
|
|
@@ -396,13 +396,9 @@ class IssueReporter {
|
|
|
396
396
|
|
|
397
397
|
setTimeout(() => {
|
|
398
398
|
if (isArray) {
|
|
399
|
-
payload = payload.map(message =>
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
});
|
|
403
|
-
} else {
|
|
404
|
-
// $FlowFixMe
|
|
405
|
-
payload._retry = retry + 1;
|
|
399
|
+
payload = payload.map(message => this._writeRetryCount(message, retry + 1));
|
|
400
|
+
} else if (payload && typeof payload === 'object') {
|
|
401
|
+
payload = this._writeRetryCount(payload, retry + 1);
|
|
406
402
|
}
|
|
407
403
|
|
|
408
404
|
this._sendDebugToGrafana(payload, retry + 1);
|
|
@@ -410,6 +406,15 @@ class IssueReporter {
|
|
|
410
406
|
});
|
|
411
407
|
}
|
|
412
408
|
|
|
409
|
+
_writeRetryCount(message , count ) {
|
|
410
|
+
if (message && typeof message === 'object') {
|
|
411
|
+
// $FlowFixMe
|
|
412
|
+
message._retry = count;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
return message;
|
|
416
|
+
}
|
|
417
|
+
|
|
413
418
|
_isLevelAbove(level1 , level2 ) {
|
|
414
419
|
const index1 = LOG_LEVELS.indexOf(level1);
|
|
415
420
|
const index2 = LOG_LEVELS.indexOf(level2);
|
|
@@ -2245,9 +2250,12 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2245
2250
|
expiration: expiration || DETAULT_EXPIRATION,
|
|
2246
2251
|
refresh_token: refreshToken,
|
|
2247
2252
|
client_id: client.clientId,
|
|
2248
|
-
tenant_id: tenantId,
|
|
2249
2253
|
};
|
|
2250
2254
|
|
|
2255
|
+
if (tenantId) {
|
|
2256
|
+
body.tenant_id = tenantId;
|
|
2257
|
+
}
|
|
2258
|
+
|
|
2251
2259
|
const headers = {
|
|
2252
2260
|
'Content-Type': 'application/json',
|
|
2253
2261
|
...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),
|
|
@@ -4566,6 +4574,7 @@ class ApiClient {
|
|
|
4566
4574
|
|
|
4567
4575
|
|
|
4568
4576
|
|
|
4577
|
+
|
|
4569
4578
|
|
|
4570
4579
|
|
|
4571
4580
|
|
|
@@ -4618,23 +4627,31 @@ class ApiClient {
|
|
|
4618
4627
|
return null;
|
|
4619
4628
|
}
|
|
4620
4629
|
|
|
4621
|
-
|
|
4622
|
-
this.refreshToken
|
|
4623
|
-
|
|
4624
|
-
|
|
4625
|
-
|
|
4626
|
-
|
|
4627
|
-
|
|
4628
|
-
|
|
4629
|
-
|
|
4630
|
+
try {
|
|
4631
|
+
const session = await this.auth.refreshToken(
|
|
4632
|
+
this.refreshToken,
|
|
4633
|
+
this.refreshBackend,
|
|
4634
|
+
this.refreshExpiration,
|
|
4635
|
+
this.isMobile,
|
|
4636
|
+
this.refreshTenantId,
|
|
4637
|
+
);
|
|
4638
|
+
|
|
4639
|
+
logger.info('token refreshed', { token: session.token });
|
|
4640
|
+
|
|
4641
|
+
if (this.onRefreshToken) {
|
|
4642
|
+
this.onRefreshToken(session.token, session);
|
|
4643
|
+
}
|
|
4630
4644
|
|
|
4631
|
-
|
|
4632
|
-
this.onRefreshToken(session.token, session);
|
|
4633
|
-
}
|
|
4645
|
+
this.setToken(session.token);
|
|
4634
4646
|
|
|
4635
|
-
|
|
4647
|
+
return session.token;
|
|
4648
|
+
} catch (error) {
|
|
4649
|
+
logger.error('token refresh, error', error);
|
|
4636
4650
|
|
|
4637
|
-
|
|
4651
|
+
if (this.onRefreshTokenError) {
|
|
4652
|
+
this.onRefreshTokenError(error);
|
|
4653
|
+
}
|
|
4654
|
+
}
|
|
4638
4655
|
}
|
|
4639
4656
|
|
|
4640
4657
|
setToken(token ) {
|
|
@@ -4657,6 +4674,10 @@ class ApiClient {
|
|
|
4657
4674
|
this.onRefreshToken = onRefreshToken;
|
|
4658
4675
|
}
|
|
4659
4676
|
|
|
4677
|
+
setOnRefreshTokenError(callback ) {
|
|
4678
|
+
this.onRefreshTokenError = callback;
|
|
4679
|
+
}
|
|
4680
|
+
|
|
4660
4681
|
setRefreshExpiration(refreshExpiration ) {
|
|
4661
4682
|
this.refreshExpiration = refreshExpiration;
|
|
4662
4683
|
}
|
|
@@ -4692,7 +4713,9 @@ global.wazoClients = global.wazoClients || {};
|
|
|
4692
4713
|
global.wazoClientId = global.wazoClientId || {};
|
|
4693
4714
|
global.wazoClientToken = global.wazoClientToken || {};
|
|
4694
4715
|
global.wazoRefreshToken = global.wazoRefreshToken || {};
|
|
4716
|
+
global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
|
|
4695
4717
|
global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
|
|
4718
|
+
global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
|
|
4696
4719
|
global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
|
|
4697
4720
|
global.wazoRefreshBackend = global.wazoRefreshBackend || {};
|
|
4698
4721
|
global.wazoIsMobile = global.wazoIsMobile || {};
|
|
@@ -4714,10 +4737,18 @@ const setRefreshToken = (newRefreshToken , forServer = null) =>
|
|
|
4714
4737
|
global.wazoRefreshToken[forServer] = newRefreshToken;
|
|
4715
4738
|
};
|
|
4716
4739
|
|
|
4740
|
+
const setRefreshTenantId = (refreshTenantId , forServer = null) => {
|
|
4741
|
+
global.wazoRefreshTenantId[forServer] = refreshTenantId;
|
|
4742
|
+
};
|
|
4743
|
+
|
|
4717
4744
|
const setOnRefreshToken = (onRefreshToken , forServer = null) => {
|
|
4718
4745
|
global.wazoOnRefreshToken[forServer] = onRefreshToken;
|
|
4719
4746
|
};
|
|
4720
4747
|
|
|
4748
|
+
const setOnRefreshTokenError = (callback , forServer = null) => {
|
|
4749
|
+
global.wazoOnRefreshTokenError[forServer] = callback;
|
|
4750
|
+
};
|
|
4751
|
+
|
|
4721
4752
|
const setRefreshExpiration = (refreshExpiration , forServer = null) => {
|
|
4722
4753
|
global.wazoRefreshExpiration[forServer] = refreshExpiration;
|
|
4723
4754
|
};
|
|
@@ -4744,12 +4775,20 @@ const fillClient = (apiClient ) => {
|
|
|
4744
4775
|
|
|
4745
4776
|
apiClient.setRefreshToken(global.wazoRefreshToken[server] || global.wazoRefreshToken[null] || apiClient.refreshToken);
|
|
4746
4777
|
|
|
4778
|
+
apiClient.setRefreshTenantId(
|
|
4779
|
+
global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId,
|
|
4780
|
+
);
|
|
4781
|
+
|
|
4747
4782
|
apiClient.setFetchOptions(global.wazoFetchOptions[server] || global.wazoFetchOptions[null] || apiClient.fetchOptions);
|
|
4748
4783
|
|
|
4749
4784
|
apiClient.setOnRefreshToken(
|
|
4750
4785
|
global.wazoOnRefreshToken[server] || global.wazoOnRefreshToken[null] || apiClient.onRefreshToken,
|
|
4751
4786
|
);
|
|
4752
4787
|
|
|
4788
|
+
apiClient.setOnRefreshTokenError(
|
|
4789
|
+
global.wazoOnRefreshTokenError[server] || global.wazoOnRefreshTokenError[null] || apiClient.onRefreshTokenError,
|
|
4790
|
+
);
|
|
4791
|
+
|
|
4753
4792
|
apiClient.setRefreshExpiration(
|
|
4754
4793
|
global.wazoRefreshExpiration[server] || global.wazoRefreshExpiration[null] || apiClient.refreshExpiration,
|
|
4755
4794
|
);
|
|
@@ -4763,7 +4802,7 @@ const fillClient = (apiClient ) => {
|
|
|
4763
4802
|
return apiClient;
|
|
4764
4803
|
};
|
|
4765
4804
|
|
|
4766
|
-
var getApiClient = (forServer
|
|
4805
|
+
var getApiClient = (forServer = null) => {
|
|
4767
4806
|
const server = forServer || global.wazoCurrentServer || '';
|
|
4768
4807
|
if (server in global.wazoClients) {
|
|
4769
4808
|
return fillClient(global.wazoClients[server]);
|
|
@@ -4775,4 +4814,4 @@ var getApiClient = (forServer ) => {
|
|
|
4775
4814
|
};
|
|
4776
4815
|
|
|
4777
4816
|
export default getApiClient;
|
|
4778
|
-
export { setApiClientId, setApiToken, setCurrentServer, setFetchOptions, setIsMobile, setOnRefreshToken, setRefreshBackend, setRefreshExpiration, setRefreshToken };
|
|
4817
|
+
export { setApiClientId, setApiToken, setCurrentServer, setFetchOptions, setIsMobile, setOnRefreshToken, setOnRefreshTokenError, setRefreshBackend, setRefreshExpiration, setRefreshTenantId, setRefreshToken };
|