@wazo/sdk 0.38.9 → 0.38.10
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 +2 -2
- package/esm/__tests__/api-client.test.js +21 -0
- package/esm/__tests__/web-rtc-client.test.js +21 -0
- package/esm/api/auth.js +12 -0
- package/esm/api/ctid-ng.js +1 -0
- package/esm/api-client.js +21 -0
- package/esm/checker/Checker.js +21 -0
- package/esm/checker/checks/aor.js +21 -0
- package/esm/checker/checks/api.js +21 -0
- package/esm/checker/checks/index.js +21 -0
- package/esm/checker/checks/webrtc-transport.js +21 -0
- package/esm/checker/checks/webrtc.js +21 -0
- package/esm/domain/AdHocAPIConference.js +28 -2
- package/esm/domain/Features.js +28 -2
- package/esm/domain/Phone/CTIPhone.js +28 -2
- package/esm/domain/Phone/WebRTCPhone.js +1 -0
- package/esm/index.js +73 -6
- package/esm/service/CallApi.js +28 -2
- package/esm/service/getApiClient.js +34 -3
- package/esm/simple/Auth.js +74 -7
- package/esm/simple/Configuration.js +73 -6
- package/esm/simple/Directory.js +28 -2
- package/esm/simple/Phone.js +73 -6
- package/esm/simple/Softphone.js +5 -0
- package/esm/simple/index.js +73 -6
- package/esm/simple/room/LocalParticipant.js +73 -6
- package/esm/simple/room/Participant.js +73 -6
- package/esm/simple/room/RemoteParticipant.js +73 -6
- package/esm/simple/room/Room.js +73 -6
- package/esm/simple/room/SipRoom.js +73 -6
- package/esm/simple/room/Stream.js +73 -6
- package/esm/simple/room/__tests__/Participant.test.js +73 -6
- package/esm/simple/room/__tests__/RemoteParticipant.test.js +73 -6
- package/esm/simple/utils.js +73 -6
- package/esm/web-rtc-client.js +21 -0
- package/lib/__tests__/api-client.test.js +21 -0
- package/lib/__tests__/web-rtc-client.test.js +21 -0
- package/lib/api/auth.js +12 -0
- package/lib/api/ctid-ng.js +1 -0
- package/lib/api-client.js +21 -0
- package/lib/checker/Checker.js +21 -0
- package/lib/checker/checks/aor.js +21 -0
- package/lib/checker/checks/api.js +21 -0
- package/lib/checker/checks/index.js +21 -0
- package/lib/checker/checks/webrtc-transport.js +21 -0
- package/lib/checker/checks/webrtc.js +21 -0
- package/lib/domain/AdHocAPIConference.js +28 -2
- package/lib/domain/Features.js +28 -2
- package/lib/domain/Phone/CTIPhone.js +28 -2
- package/lib/domain/Phone/WebRTCPhone.js +1 -0
- package/lib/index.js +73 -6
- package/lib/service/CallApi.js +28 -2
- package/lib/service/getApiClient.js +34 -2
- package/lib/simple/Auth.js +74 -6
- package/lib/simple/Configuration.js +73 -6
- package/lib/simple/Directory.js +28 -2
- package/lib/simple/Phone.js +73 -6
- package/lib/simple/Softphone.js +5 -0
- package/lib/simple/index.js +73 -6
- package/lib/simple/room/LocalParticipant.js +73 -6
- package/lib/simple/room/Participant.js +73 -6
- package/lib/simple/room/RemoteParticipant.js +73 -6
- package/lib/simple/room/Room.js +73 -6
- package/lib/simple/room/SipRoom.js +73 -6
- package/lib/simple/room/Stream.js +73 -6
- package/lib/simple/room/__tests__/Participant.test.js +73 -6
- package/lib/simple/room/__tests__/RemoteParticipant.test.js +73 -6
- package/lib/simple/utils.js +73 -6
- package/lib/web-rtc-client.js +21 -0
- package/package.json +2 -2
- package/src/api/auth.js +12 -0
- package/src/api-client.js +8 -0
- package/src/service/getApiClient.js +13 -2
- package/src/simple/Auth.js +35 -4
- package/src/simple/Softphone.js +5 -0
- package/src/simple/index.js +2 -1
package/lib/simple/Auth.js
CHANGED
|
@@ -2241,6 +2241,7 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2241
2241
|
|
|
2242
2242
|
|
|
2243
2243
|
|
|
2244
|
+
|
|
2244
2245
|
) {
|
|
2245
2246
|
const body = {
|
|
2246
2247
|
backend: params.backend || DEFAULT_BACKEND_USER,
|
|
@@ -2261,9 +2262,14 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2261
2262
|
}
|
|
2262
2263
|
|
|
2263
2264
|
if (params.tenantId) {
|
|
2265
|
+
console.warn('Use of `tenantId` is deprecated when calling logIn() method, use `domainName` instead.');
|
|
2264
2266
|
body.tenant_id = params.tenantId;
|
|
2265
2267
|
}
|
|
2266
2268
|
|
|
2269
|
+
if (params.domainName) {
|
|
2270
|
+
body.domain_name = params.domainName;
|
|
2271
|
+
}
|
|
2272
|
+
|
|
2267
2273
|
return client.post(`${baseUrl}/token`, body, headers).then(response => Session.parse(response));
|
|
2268
2274
|
},
|
|
2269
2275
|
|
|
@@ -2276,6 +2282,7 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2276
2282
|
expiration ,
|
|
2277
2283
|
isMobile = false,
|
|
2278
2284
|
tenantId ,
|
|
2285
|
+
domainName ,
|
|
2279
2286
|
) => {
|
|
2280
2287
|
const body = {
|
|
2281
2288
|
backend: backend || DEFAULT_BACKEND_USER,
|
|
@@ -2285,9 +2292,14 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2285
2292
|
};
|
|
2286
2293
|
|
|
2287
2294
|
if (tenantId) {
|
|
2295
|
+
console.warn('Use of `tenantId` is deprecated when calling refreshToken() method, use `domainName` instead.');
|
|
2288
2296
|
body.tenant_id = tenantId;
|
|
2289
2297
|
}
|
|
2290
2298
|
|
|
2299
|
+
if (domainName) {
|
|
2300
|
+
body.domain_name = domainName;
|
|
2301
|
+
}
|
|
2302
|
+
|
|
2291
2303
|
const headers = {
|
|
2292
2304
|
'Content-Type': 'application/json',
|
|
2293
2305
|
...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),
|
|
@@ -5585,6 +5597,7 @@ class ApiClient {
|
|
|
5585
5597
|
|
|
5586
5598
|
|
|
5587
5599
|
|
|
5600
|
+
|
|
5588
5601
|
|
|
5589
5602
|
|
|
5590
5603
|
|
|
@@ -5626,6 +5639,7 @@ class ApiClient {
|
|
|
5626
5639
|
refreshToken: this.refreshToken,
|
|
5627
5640
|
refreshBackend: this.refreshBackend,
|
|
5628
5641
|
refreshTenantId: this.refreshTenantId,
|
|
5642
|
+
refreshDomainName: this.refreshDomainName,
|
|
5629
5643
|
refreshExpiration: this.refreshExpiration,
|
|
5630
5644
|
isMobile: this.isMobile,
|
|
5631
5645
|
});
|
|
@@ -5641,6 +5655,7 @@ class ApiClient {
|
|
|
5641
5655
|
this.refreshExpiration,
|
|
5642
5656
|
this.isMobile,
|
|
5643
5657
|
this.refreshTenantId,
|
|
5658
|
+
this.refreshDomainName,
|
|
5644
5659
|
);
|
|
5645
5660
|
|
|
5646
5661
|
logger$a.info('token refreshed', { token: session.token });
|
|
@@ -5694,9 +5709,14 @@ class ApiClient {
|
|
|
5694
5709
|
}
|
|
5695
5710
|
|
|
5696
5711
|
setRefreshTenantId(tenantId ) {
|
|
5712
|
+
console.warn('Use of `setRefreshTenantId` is deprecated, use `setRefreshDomainName` instead');
|
|
5697
5713
|
this.refreshTenantId = tenantId;
|
|
5698
5714
|
}
|
|
5699
5715
|
|
|
5716
|
+
setRefreshDomainName(domainName ) {
|
|
5717
|
+
this.refreshDomainName = domainName;
|
|
5718
|
+
}
|
|
5719
|
+
|
|
5700
5720
|
setIsMobile(isMobile ) {
|
|
5701
5721
|
this.isMobile = isMobile;
|
|
5702
5722
|
}
|
|
@@ -5721,6 +5741,7 @@ global.wazoClientId = global.wazoClientId || {};
|
|
|
5721
5741
|
global.wazoClientToken = global.wazoClientToken || {};
|
|
5722
5742
|
global.wazoRefreshToken = global.wazoRefreshToken || {};
|
|
5723
5743
|
global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
|
|
5744
|
+
global.wazoRefreshDomainName = global.wazoRefreshDomainName || {};
|
|
5724
5745
|
global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
|
|
5725
5746
|
global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
|
|
5726
5747
|
global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
|
|
@@ -5745,9 +5766,14 @@ const setRefreshToken = (newRefreshToken , forServer = null) =>
|
|
|
5745
5766
|
};
|
|
5746
5767
|
|
|
5747
5768
|
const setRefreshTenantId = (refreshTenantId , forServer = null) => {
|
|
5769
|
+
console.warn('Use of `setRefreshTenantId` is deprecated, please use `setRefreshDomainName` instead');
|
|
5748
5770
|
global.wazoRefreshTenantId[forServer] = refreshTenantId;
|
|
5749
5771
|
};
|
|
5750
5772
|
|
|
5773
|
+
const setRefreshDomainName = (refreshDomainName , forServer = null) => {
|
|
5774
|
+
global.wazoRefreshDomainName[forServer] = refreshDomainName;
|
|
5775
|
+
};
|
|
5776
|
+
|
|
5751
5777
|
const setOnRefreshToken = (onRefreshToken , forServer = null) => {
|
|
5752
5778
|
global.wazoOnRefreshToken[forServer] = onRefreshToken;
|
|
5753
5779
|
};
|
|
@@ -5766,6 +5792,7 @@ const setFetchOptions = (fetchOptions , forServer = null) => {
|
|
|
5766
5792
|
|
|
5767
5793
|
const fillClient = (apiClient ) => {
|
|
5768
5794
|
const { server, token, clientId } = apiClient.client;
|
|
5795
|
+
const tenantId = global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId;
|
|
5769
5796
|
|
|
5770
5797
|
// try with null server when dealing with non-related server info
|
|
5771
5798
|
apiClient.setToken(global.wazoClientToken[server] || global.wazoClientToken[null] || token);
|
|
@@ -5774,8 +5801,12 @@ const fillClient = (apiClient ) => {
|
|
|
5774
5801
|
|
|
5775
5802
|
apiClient.setRefreshToken(global.wazoRefreshToken[server] || global.wazoRefreshToken[null] || apiClient.refreshToken);
|
|
5776
5803
|
|
|
5777
|
-
|
|
5778
|
-
|
|
5804
|
+
if (tenantId) {
|
|
5805
|
+
apiClient.setRefreshTenantId(tenantId);
|
|
5806
|
+
}
|
|
5807
|
+
|
|
5808
|
+
apiClient.setRefreshDomainName(
|
|
5809
|
+
global.wazoRefreshDomainName[server] || global.wazoRefreshDomainName[null] || apiClient.refreshDomainName,
|
|
5779
5810
|
);
|
|
5780
5811
|
|
|
5781
5812
|
apiClient.setFetchOptions(global.wazoFetchOptions[server] || global.wazoFetchOptions[null] || apiClient.fetchOptions);
|
|
@@ -14021,6 +14052,7 @@ class Softphone {
|
|
|
14021
14052
|
wrapUpDuration,
|
|
14022
14053
|
enableAgent = true,
|
|
14023
14054
|
tenantId,
|
|
14055
|
+
domainName,
|
|
14024
14056
|
debug = false,
|
|
14025
14057
|
} = {}) {
|
|
14026
14058
|
this.url = url || 'https://softphone.wazo.io';
|
|
@@ -14045,8 +14077,12 @@ class Softphone {
|
|
|
14045
14077
|
config.port = port;
|
|
14046
14078
|
}
|
|
14047
14079
|
if (tenantId) {
|
|
14080
|
+
console.warn('Use of `tenantId` is deprecated when calling `Softphone.init()`, use `domainName` instead');
|
|
14048
14081
|
config.tenantId = tenantId;
|
|
14049
14082
|
}
|
|
14083
|
+
if (domainName) {
|
|
14084
|
+
config.domainName = domainName;
|
|
14085
|
+
}
|
|
14050
14086
|
if (wrapUpDuration) {
|
|
14051
14087
|
config.wrapUpDuration = wrapUpDuration;
|
|
14052
14088
|
}
|
|
@@ -14367,6 +14403,7 @@ const Wazo = {
|
|
|
14367
14403
|
CanceledCallError,
|
|
14368
14404
|
SFUNotAvailableError,
|
|
14369
14405
|
NoTenantIdError,
|
|
14406
|
+
NoDomainNameError,
|
|
14370
14407
|
};
|
|
14371
14408
|
|
|
14372
14409
|
if (window) {
|
|
@@ -14381,6 +14418,7 @@ if (global) {
|
|
|
14381
14418
|
class InvalidSubscription extends Error {}
|
|
14382
14419
|
class InvalidAuthorization extends Error {}
|
|
14383
14420
|
class NoTenantIdError extends Error {}
|
|
14421
|
+
class NoDomainNameError extends Error {}
|
|
14384
14422
|
|
|
14385
14423
|
const logger = IssueReporter$1.loggerFor('simple-auth');
|
|
14386
14424
|
|
|
@@ -14444,9 +14482,24 @@ class Auth {
|
|
|
14444
14482
|
setFetchOptions(options);
|
|
14445
14483
|
}
|
|
14446
14484
|
|
|
14447
|
-
async logIn(username , password , backend ,
|
|
14448
|
-
|
|
14449
|
-
|
|
14485
|
+
async logIn(username , password , backend , extra ) {
|
|
14486
|
+
let tenantId = null;
|
|
14487
|
+
let domainName = null;
|
|
14488
|
+
if (typeof extra === 'string') {
|
|
14489
|
+
tenantId = extra;
|
|
14490
|
+
}
|
|
14491
|
+
if (extra && typeof extra === 'object') {
|
|
14492
|
+
domainName = extra.domainName;
|
|
14493
|
+
}
|
|
14494
|
+
|
|
14495
|
+
if (backend && backend !== this.BACKEND_WAZO && !tenantId && !domainName) {
|
|
14496
|
+
if (!tenantId) {
|
|
14497
|
+
throw new NoTenantIdError('No tenant id');
|
|
14498
|
+
}
|
|
14499
|
+
|
|
14500
|
+
if (!domainName) {
|
|
14501
|
+
throw new NoDomainNameError('No domain name');
|
|
14502
|
+
}
|
|
14450
14503
|
}
|
|
14451
14504
|
|
|
14452
14505
|
this.authenticated = false;
|
|
@@ -14456,6 +14509,7 @@ class Auth {
|
|
|
14456
14509
|
password,
|
|
14457
14510
|
backend,
|
|
14458
14511
|
tenantId,
|
|
14512
|
+
domainName,
|
|
14459
14513
|
expiration: this.expiration,
|
|
14460
14514
|
mobile: this.mobile,
|
|
14461
14515
|
});
|
|
@@ -14464,7 +14518,13 @@ class Auth {
|
|
|
14464
14518
|
getApiClient().setRefreshBackend(backend);
|
|
14465
14519
|
}
|
|
14466
14520
|
|
|
14467
|
-
|
|
14521
|
+
if (tenantId) {
|
|
14522
|
+
getApiClient().setRefreshTenantId(tenantId);
|
|
14523
|
+
}
|
|
14524
|
+
|
|
14525
|
+
if (domainName) {
|
|
14526
|
+
getApiClient().setRefreshDomainName(domainName);
|
|
14527
|
+
}
|
|
14468
14528
|
|
|
14469
14529
|
return this._onAuthenticated(rawSession);
|
|
14470
14530
|
}
|
|
@@ -14563,11 +14623,18 @@ class Auth {
|
|
|
14563
14623
|
}
|
|
14564
14624
|
|
|
14565
14625
|
setRefreshTenantId(refreshTenantId ) {
|
|
14626
|
+
console.warn('Use of `setRefreshTenantId` is deprecated, use `setRefreshDomainName` instead.');
|
|
14566
14627
|
setRefreshTenantId(refreshTenantId);
|
|
14567
14628
|
|
|
14568
14629
|
getApiClient().setRefreshTenantId(refreshTenantId);
|
|
14569
14630
|
}
|
|
14570
14631
|
|
|
14632
|
+
setRefreshDomainName(domainName ) {
|
|
14633
|
+
setRefreshDomainName(domainName);
|
|
14634
|
+
|
|
14635
|
+
getApiClient().setRefreshDomainName(domainName);
|
|
14636
|
+
}
|
|
14637
|
+
|
|
14571
14638
|
forceRefreshToken() {
|
|
14572
14639
|
getApiClient().forceRefreshToken();
|
|
14573
14640
|
}
|
|
@@ -14679,5 +14746,6 @@ var Auth$1 = global.wazoAuthInstance;
|
|
|
14679
14746
|
|
|
14680
14747
|
exports.InvalidAuthorization = InvalidAuthorization;
|
|
14681
14748
|
exports.InvalidSubscription = InvalidSubscription;
|
|
14749
|
+
exports.NoDomainNameError = NoDomainNameError;
|
|
14682
14750
|
exports.NoTenantIdError = NoTenantIdError;
|
|
14683
14751
|
exports.default = Auth$1;
|
|
@@ -2239,6 +2239,7 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2239
2239
|
|
|
2240
2240
|
|
|
2241
2241
|
|
|
2242
|
+
|
|
2242
2243
|
) {
|
|
2243
2244
|
const body = {
|
|
2244
2245
|
backend: params.backend || DEFAULT_BACKEND_USER,
|
|
@@ -2259,9 +2260,14 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2259
2260
|
}
|
|
2260
2261
|
|
|
2261
2262
|
if (params.tenantId) {
|
|
2263
|
+
console.warn('Use of `tenantId` is deprecated when calling logIn() method, use `domainName` instead.');
|
|
2262
2264
|
body.tenant_id = params.tenantId;
|
|
2263
2265
|
}
|
|
2264
2266
|
|
|
2267
|
+
if (params.domainName) {
|
|
2268
|
+
body.domain_name = params.domainName;
|
|
2269
|
+
}
|
|
2270
|
+
|
|
2265
2271
|
return client.post(`${baseUrl}/token`, body, headers).then(response => Session.parse(response));
|
|
2266
2272
|
},
|
|
2267
2273
|
|
|
@@ -2274,6 +2280,7 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2274
2280
|
expiration ,
|
|
2275
2281
|
isMobile = false,
|
|
2276
2282
|
tenantId ,
|
|
2283
|
+
domainName ,
|
|
2277
2284
|
) => {
|
|
2278
2285
|
const body = {
|
|
2279
2286
|
backend: backend || DEFAULT_BACKEND_USER,
|
|
@@ -2283,9 +2290,14 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2283
2290
|
};
|
|
2284
2291
|
|
|
2285
2292
|
if (tenantId) {
|
|
2293
|
+
console.warn('Use of `tenantId` is deprecated when calling refreshToken() method, use `domainName` instead.');
|
|
2286
2294
|
body.tenant_id = tenantId;
|
|
2287
2295
|
}
|
|
2288
2296
|
|
|
2297
|
+
if (domainName) {
|
|
2298
|
+
body.domain_name = domainName;
|
|
2299
|
+
}
|
|
2300
|
+
|
|
2289
2301
|
const headers = {
|
|
2290
2302
|
'Content-Type': 'application/json',
|
|
2291
2303
|
...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),
|
|
@@ -5583,6 +5595,7 @@ class ApiClient {
|
|
|
5583
5595
|
|
|
5584
5596
|
|
|
5585
5597
|
|
|
5598
|
+
|
|
5586
5599
|
|
|
5587
5600
|
|
|
5588
5601
|
|
|
@@ -5624,6 +5637,7 @@ class ApiClient {
|
|
|
5624
5637
|
refreshToken: this.refreshToken,
|
|
5625
5638
|
refreshBackend: this.refreshBackend,
|
|
5626
5639
|
refreshTenantId: this.refreshTenantId,
|
|
5640
|
+
refreshDomainName: this.refreshDomainName,
|
|
5627
5641
|
refreshExpiration: this.refreshExpiration,
|
|
5628
5642
|
isMobile: this.isMobile,
|
|
5629
5643
|
});
|
|
@@ -5639,6 +5653,7 @@ class ApiClient {
|
|
|
5639
5653
|
this.refreshExpiration,
|
|
5640
5654
|
this.isMobile,
|
|
5641
5655
|
this.refreshTenantId,
|
|
5656
|
+
this.refreshDomainName,
|
|
5642
5657
|
);
|
|
5643
5658
|
|
|
5644
5659
|
logger$a.info('token refreshed', { token: session.token });
|
|
@@ -5692,9 +5707,14 @@ class ApiClient {
|
|
|
5692
5707
|
}
|
|
5693
5708
|
|
|
5694
5709
|
setRefreshTenantId(tenantId ) {
|
|
5710
|
+
console.warn('Use of `setRefreshTenantId` is deprecated, use `setRefreshDomainName` instead');
|
|
5695
5711
|
this.refreshTenantId = tenantId;
|
|
5696
5712
|
}
|
|
5697
5713
|
|
|
5714
|
+
setRefreshDomainName(domainName ) {
|
|
5715
|
+
this.refreshDomainName = domainName;
|
|
5716
|
+
}
|
|
5717
|
+
|
|
5698
5718
|
setIsMobile(isMobile ) {
|
|
5699
5719
|
this.isMobile = isMobile;
|
|
5700
5720
|
}
|
|
@@ -5719,6 +5739,7 @@ global.wazoClientId = global.wazoClientId || {};
|
|
|
5719
5739
|
global.wazoClientToken = global.wazoClientToken || {};
|
|
5720
5740
|
global.wazoRefreshToken = global.wazoRefreshToken || {};
|
|
5721
5741
|
global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
|
|
5742
|
+
global.wazoRefreshDomainName = global.wazoRefreshDomainName || {};
|
|
5722
5743
|
global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
|
|
5723
5744
|
global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
|
|
5724
5745
|
global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
|
|
@@ -5743,9 +5764,14 @@ const setRefreshToken = (newRefreshToken , forServer = null) =>
|
|
|
5743
5764
|
};
|
|
5744
5765
|
|
|
5745
5766
|
const setRefreshTenantId = (refreshTenantId , forServer = null) => {
|
|
5767
|
+
console.warn('Use of `setRefreshTenantId` is deprecated, please use `setRefreshDomainName` instead');
|
|
5746
5768
|
global.wazoRefreshTenantId[forServer] = refreshTenantId;
|
|
5747
5769
|
};
|
|
5748
5770
|
|
|
5771
|
+
const setRefreshDomainName = (refreshDomainName , forServer = null) => {
|
|
5772
|
+
global.wazoRefreshDomainName[forServer] = refreshDomainName;
|
|
5773
|
+
};
|
|
5774
|
+
|
|
5749
5775
|
const setOnRefreshToken = (onRefreshToken , forServer = null) => {
|
|
5750
5776
|
global.wazoOnRefreshToken[forServer] = onRefreshToken;
|
|
5751
5777
|
};
|
|
@@ -5764,6 +5790,7 @@ const setFetchOptions = (fetchOptions , forServer = null) => {
|
|
|
5764
5790
|
|
|
5765
5791
|
const fillClient = (apiClient ) => {
|
|
5766
5792
|
const { server, token, clientId } = apiClient.client;
|
|
5793
|
+
const tenantId = global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId;
|
|
5767
5794
|
|
|
5768
5795
|
// try with null server when dealing with non-related server info
|
|
5769
5796
|
apiClient.setToken(global.wazoClientToken[server] || global.wazoClientToken[null] || token);
|
|
@@ -5772,8 +5799,12 @@ const fillClient = (apiClient ) => {
|
|
|
5772
5799
|
|
|
5773
5800
|
apiClient.setRefreshToken(global.wazoRefreshToken[server] || global.wazoRefreshToken[null] || apiClient.refreshToken);
|
|
5774
5801
|
|
|
5775
|
-
|
|
5776
|
-
|
|
5802
|
+
if (tenantId) {
|
|
5803
|
+
apiClient.setRefreshTenantId(tenantId);
|
|
5804
|
+
}
|
|
5805
|
+
|
|
5806
|
+
apiClient.setRefreshDomainName(
|
|
5807
|
+
global.wazoRefreshDomainName[server] || global.wazoRefreshDomainName[null] || apiClient.refreshDomainName,
|
|
5777
5808
|
);
|
|
5778
5809
|
|
|
5779
5810
|
apiClient.setFetchOptions(global.wazoFetchOptions[server] || global.wazoFetchOptions[null] || apiClient.fetchOptions);
|
|
@@ -14002,6 +14033,7 @@ class Softphone {
|
|
|
14002
14033
|
wrapUpDuration,
|
|
14003
14034
|
enableAgent = true,
|
|
14004
14035
|
tenantId,
|
|
14036
|
+
domainName,
|
|
14005
14037
|
debug = false,
|
|
14006
14038
|
} = {}) {
|
|
14007
14039
|
this.url = url || 'https://softphone.wazo.io';
|
|
@@ -14026,8 +14058,12 @@ class Softphone {
|
|
|
14026
14058
|
config.port = port;
|
|
14027
14059
|
}
|
|
14028
14060
|
if (tenantId) {
|
|
14061
|
+
console.warn('Use of `tenantId` is deprecated when calling `Softphone.init()`, use `domainName` instead');
|
|
14029
14062
|
config.tenantId = tenantId;
|
|
14030
14063
|
}
|
|
14064
|
+
if (domainName) {
|
|
14065
|
+
config.domainName = domainName;
|
|
14066
|
+
}
|
|
14031
14067
|
if (wrapUpDuration) {
|
|
14032
14068
|
config.wrapUpDuration = wrapUpDuration;
|
|
14033
14069
|
}
|
|
@@ -14348,6 +14384,7 @@ const Wazo = {
|
|
|
14348
14384
|
CanceledCallError,
|
|
14349
14385
|
SFUNotAvailableError,
|
|
14350
14386
|
NoTenantIdError,
|
|
14387
|
+
NoDomainNameError,
|
|
14351
14388
|
};
|
|
14352
14389
|
|
|
14353
14390
|
if (window) {
|
|
@@ -14362,6 +14399,7 @@ if (global) {
|
|
|
14362
14399
|
class InvalidSubscription extends Error {}
|
|
14363
14400
|
class InvalidAuthorization extends Error {}
|
|
14364
14401
|
class NoTenantIdError extends Error {}
|
|
14402
|
+
class NoDomainNameError extends Error {}
|
|
14365
14403
|
|
|
14366
14404
|
const logger = IssueReporter$1.loggerFor('simple-auth');
|
|
14367
14405
|
|
|
@@ -14425,9 +14463,24 @@ class Auth {
|
|
|
14425
14463
|
setFetchOptions(options);
|
|
14426
14464
|
}
|
|
14427
14465
|
|
|
14428
|
-
async logIn(username , password , backend ,
|
|
14429
|
-
|
|
14430
|
-
|
|
14466
|
+
async logIn(username , password , backend , extra ) {
|
|
14467
|
+
let tenantId = null;
|
|
14468
|
+
let domainName = null;
|
|
14469
|
+
if (typeof extra === 'string') {
|
|
14470
|
+
tenantId = extra;
|
|
14471
|
+
}
|
|
14472
|
+
if (extra && typeof extra === 'object') {
|
|
14473
|
+
domainName = extra.domainName;
|
|
14474
|
+
}
|
|
14475
|
+
|
|
14476
|
+
if (backend && backend !== this.BACKEND_WAZO && !tenantId && !domainName) {
|
|
14477
|
+
if (!tenantId) {
|
|
14478
|
+
throw new NoTenantIdError('No tenant id');
|
|
14479
|
+
}
|
|
14480
|
+
|
|
14481
|
+
if (!domainName) {
|
|
14482
|
+
throw new NoDomainNameError('No domain name');
|
|
14483
|
+
}
|
|
14431
14484
|
}
|
|
14432
14485
|
|
|
14433
14486
|
this.authenticated = false;
|
|
@@ -14437,6 +14490,7 @@ class Auth {
|
|
|
14437
14490
|
password,
|
|
14438
14491
|
backend,
|
|
14439
14492
|
tenantId,
|
|
14493
|
+
domainName,
|
|
14440
14494
|
expiration: this.expiration,
|
|
14441
14495
|
mobile: this.mobile,
|
|
14442
14496
|
});
|
|
@@ -14445,7 +14499,13 @@ class Auth {
|
|
|
14445
14499
|
getApiClient().setRefreshBackend(backend);
|
|
14446
14500
|
}
|
|
14447
14501
|
|
|
14448
|
-
|
|
14502
|
+
if (tenantId) {
|
|
14503
|
+
getApiClient().setRefreshTenantId(tenantId);
|
|
14504
|
+
}
|
|
14505
|
+
|
|
14506
|
+
if (domainName) {
|
|
14507
|
+
getApiClient().setRefreshDomainName(domainName);
|
|
14508
|
+
}
|
|
14449
14509
|
|
|
14450
14510
|
return this._onAuthenticated(rawSession);
|
|
14451
14511
|
}
|
|
@@ -14544,11 +14604,18 @@ class Auth {
|
|
|
14544
14604
|
}
|
|
14545
14605
|
|
|
14546
14606
|
setRefreshTenantId(refreshTenantId ) {
|
|
14607
|
+
console.warn('Use of `setRefreshTenantId` is deprecated, use `setRefreshDomainName` instead.');
|
|
14547
14608
|
setRefreshTenantId(refreshTenantId);
|
|
14548
14609
|
|
|
14549
14610
|
getApiClient().setRefreshTenantId(refreshTenantId);
|
|
14550
14611
|
}
|
|
14551
14612
|
|
|
14613
|
+
setRefreshDomainName(domainName ) {
|
|
14614
|
+
setRefreshDomainName(domainName);
|
|
14615
|
+
|
|
14616
|
+
getApiClient().setRefreshDomainName(domainName);
|
|
14617
|
+
}
|
|
14618
|
+
|
|
14552
14619
|
forceRefreshToken() {
|
|
14553
14620
|
getApiClient().forceRefreshToken();
|
|
14554
14621
|
}
|
package/lib/simple/Directory.js
CHANGED
|
@@ -2215,6 +2215,7 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2215
2215
|
|
|
2216
2216
|
|
|
2217
2217
|
|
|
2218
|
+
|
|
2218
2219
|
) {
|
|
2219
2220
|
const body = {
|
|
2220
2221
|
backend: params.backend || DEFAULT_BACKEND_USER,
|
|
@@ -2235,9 +2236,14 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2235
2236
|
}
|
|
2236
2237
|
|
|
2237
2238
|
if (params.tenantId) {
|
|
2239
|
+
console.warn('Use of `tenantId` is deprecated when calling logIn() method, use `domainName` instead.');
|
|
2238
2240
|
body.tenant_id = params.tenantId;
|
|
2239
2241
|
}
|
|
2240
2242
|
|
|
2243
|
+
if (params.domainName) {
|
|
2244
|
+
body.domain_name = params.domainName;
|
|
2245
|
+
}
|
|
2246
|
+
|
|
2241
2247
|
return client.post(`${baseUrl}/token`, body, headers).then(response => Session.parse(response));
|
|
2242
2248
|
},
|
|
2243
2249
|
|
|
@@ -2250,6 +2256,7 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2250
2256
|
expiration ,
|
|
2251
2257
|
isMobile = false,
|
|
2252
2258
|
tenantId ,
|
|
2259
|
+
domainName ,
|
|
2253
2260
|
) => {
|
|
2254
2261
|
const body = {
|
|
2255
2262
|
backend: backend || DEFAULT_BACKEND_USER,
|
|
@@ -2259,9 +2266,14 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2259
2266
|
};
|
|
2260
2267
|
|
|
2261
2268
|
if (tenantId) {
|
|
2269
|
+
console.warn('Use of `tenantId` is deprecated when calling refreshToken() method, use `domainName` instead.');
|
|
2262
2270
|
body.tenant_id = tenantId;
|
|
2263
2271
|
}
|
|
2264
2272
|
|
|
2273
|
+
if (domainName) {
|
|
2274
|
+
body.domain_name = domainName;
|
|
2275
|
+
}
|
|
2276
|
+
|
|
2265
2277
|
const headers = {
|
|
2266
2278
|
'Content-Type': 'application/json',
|
|
2267
2279
|
...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),
|
|
@@ -4730,6 +4742,7 @@ class ApiClient {
|
|
|
4730
4742
|
|
|
4731
4743
|
|
|
4732
4744
|
|
|
4745
|
+
|
|
4733
4746
|
|
|
4734
4747
|
|
|
4735
4748
|
|
|
@@ -4771,6 +4784,7 @@ class ApiClient {
|
|
|
4771
4784
|
refreshToken: this.refreshToken,
|
|
4772
4785
|
refreshBackend: this.refreshBackend,
|
|
4773
4786
|
refreshTenantId: this.refreshTenantId,
|
|
4787
|
+
refreshDomainName: this.refreshDomainName,
|
|
4774
4788
|
refreshExpiration: this.refreshExpiration,
|
|
4775
4789
|
isMobile: this.isMobile,
|
|
4776
4790
|
});
|
|
@@ -4786,6 +4800,7 @@ class ApiClient {
|
|
|
4786
4800
|
this.refreshExpiration,
|
|
4787
4801
|
this.isMobile,
|
|
4788
4802
|
this.refreshTenantId,
|
|
4803
|
+
this.refreshDomainName,
|
|
4789
4804
|
);
|
|
4790
4805
|
|
|
4791
4806
|
logger.info('token refreshed', { token: session.token });
|
|
@@ -4839,9 +4854,14 @@ class ApiClient {
|
|
|
4839
4854
|
}
|
|
4840
4855
|
|
|
4841
4856
|
setRefreshTenantId(tenantId ) {
|
|
4857
|
+
console.warn('Use of `setRefreshTenantId` is deprecated, use `setRefreshDomainName` instead');
|
|
4842
4858
|
this.refreshTenantId = tenantId;
|
|
4843
4859
|
}
|
|
4844
4860
|
|
|
4861
|
+
setRefreshDomainName(domainName ) {
|
|
4862
|
+
this.refreshDomainName = domainName;
|
|
4863
|
+
}
|
|
4864
|
+
|
|
4845
4865
|
setIsMobile(isMobile ) {
|
|
4846
4866
|
this.isMobile = isMobile;
|
|
4847
4867
|
}
|
|
@@ -4866,6 +4886,7 @@ global.wazoClientId = global.wazoClientId || {};
|
|
|
4866
4886
|
global.wazoClientToken = global.wazoClientToken || {};
|
|
4867
4887
|
global.wazoRefreshToken = global.wazoRefreshToken || {};
|
|
4868
4888
|
global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
|
|
4889
|
+
global.wazoRefreshDomainName = global.wazoRefreshDomainName || {};
|
|
4869
4890
|
global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
|
|
4870
4891
|
global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
|
|
4871
4892
|
global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
|
|
@@ -4875,6 +4896,7 @@ global.wazoFetchOptions = global.wazoFetchOptions || {};
|
|
|
4875
4896
|
|
|
4876
4897
|
const fillClient = (apiClient ) => {
|
|
4877
4898
|
const { server, token, clientId } = apiClient.client;
|
|
4899
|
+
const tenantId = global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId;
|
|
4878
4900
|
|
|
4879
4901
|
// try with null server when dealing with non-related server info
|
|
4880
4902
|
apiClient.setToken(global.wazoClientToken[server] || global.wazoClientToken[null] || token);
|
|
@@ -4883,8 +4905,12 @@ const fillClient = (apiClient ) => {
|
|
|
4883
4905
|
|
|
4884
4906
|
apiClient.setRefreshToken(global.wazoRefreshToken[server] || global.wazoRefreshToken[null] || apiClient.refreshToken);
|
|
4885
4907
|
|
|
4886
|
-
|
|
4887
|
-
|
|
4908
|
+
if (tenantId) {
|
|
4909
|
+
apiClient.setRefreshTenantId(tenantId);
|
|
4910
|
+
}
|
|
4911
|
+
|
|
4912
|
+
apiClient.setRefreshDomainName(
|
|
4913
|
+
global.wazoRefreshDomainName[server] || global.wazoRefreshDomainName[null] || apiClient.refreshDomainName,
|
|
4888
4914
|
);
|
|
4889
4915
|
|
|
4890
4916
|
apiClient.setFetchOptions(global.wazoFetchOptions[server] || global.wazoFetchOptions[null] || apiClient.fetchOptions);
|