@wazo/sdk 0.38.9 → 0.38.12
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 +32 -7
- 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 +32 -7
- package/esm/checker/checks/aor.js +21 -0
- package/esm/checker/checks/api.js +21 -0
- package/esm/checker/checks/index.js +32 -7
- package/esm/checker/checks/webrtc-transport.js +32 -7
- package/esm/checker/checks/webrtc.js +32 -7
- 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 +3 -2
- package/esm/index.js +86 -15
- package/esm/service/CallApi.js +28 -2
- package/esm/service/getApiClient.js +34 -3
- package/esm/simple/Auth.js +87 -16
- package/esm/simple/Configuration.js +86 -15
- package/esm/simple/Directory.js +28 -2
- package/esm/simple/Phone.js +86 -15
- package/esm/simple/Softphone.js +5 -0
- package/esm/simple/index.js +86 -15
- package/esm/simple/room/LocalParticipant.js +86 -15
- package/esm/simple/room/Participant.js +86 -15
- package/esm/simple/room/RemoteParticipant.js +86 -15
- package/esm/simple/room/Room.js +86 -15
- package/esm/simple/room/SipRoom.js +86 -15
- package/esm/simple/room/Stream.js +86 -15
- package/esm/simple/room/__tests__/Participant.test.js +86 -15
- package/esm/simple/room/__tests__/RemoteParticipant.test.js +86 -15
- package/esm/simple/utils.js +86 -15
- package/esm/web-rtc-client.js +32 -7
- package/lib/__tests__/api-client.test.js +21 -0
- package/lib/__tests__/web-rtc-client.test.js +32 -7
- 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 +32 -7
- package/lib/checker/checks/aor.js +21 -0
- package/lib/checker/checks/api.js +21 -0
- package/lib/checker/checks/index.js +32 -7
- package/lib/checker/checks/webrtc-transport.js +32 -7
- package/lib/checker/checks/webrtc.js +32 -7
- 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 +3 -2
- package/lib/index.js +86 -15
- package/lib/service/CallApi.js +28 -2
- package/lib/service/getApiClient.js +34 -2
- package/lib/simple/Auth.js +87 -15
- package/lib/simple/Configuration.js +86 -15
- package/lib/simple/Directory.js +28 -2
- package/lib/simple/Phone.js +86 -15
- package/lib/simple/Softphone.js +5 -0
- package/lib/simple/index.js +86 -15
- package/lib/simple/room/LocalParticipant.js +86 -15
- package/lib/simple/room/Participant.js +86 -15
- package/lib/simple/room/RemoteParticipant.js +86 -15
- package/lib/simple/room/Room.js +86 -15
- package/lib/simple/room/SipRoom.js +86 -15
- package/lib/simple/room/Stream.js +86 -15
- package/lib/simple/room/__tests__/Participant.test.js +86 -15
- package/lib/simple/room/__tests__/RemoteParticipant.test.js +86 -15
- package/lib/simple/utils.js +86 -15
- package/lib/web-rtc-client.js +32 -7
- package/package.json +2 -2
- package/src/api/auth.js +12 -0
- package/src/api-client.js +8 -0
- package/src/domain/Phone/WebRTCPhone.js +2 -2
- 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/src/web-rtc-client.js +11 -7
package/esm/simple/Auth.js
CHANGED
|
@@ -2229,6 +2229,7 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2229
2229
|
|
|
2230
2230
|
|
|
2231
2231
|
|
|
2232
|
+
|
|
2232
2233
|
) {
|
|
2233
2234
|
const body = {
|
|
2234
2235
|
backend: params.backend || DEFAULT_BACKEND_USER,
|
|
@@ -2249,9 +2250,14 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2249
2250
|
}
|
|
2250
2251
|
|
|
2251
2252
|
if (params.tenantId) {
|
|
2253
|
+
console.warn('Use of `tenantId` is deprecated when calling logIn() method, use `domainName` instead.');
|
|
2252
2254
|
body.tenant_id = params.tenantId;
|
|
2253
2255
|
}
|
|
2254
2256
|
|
|
2257
|
+
if (params.domainName) {
|
|
2258
|
+
body.domain_name = params.domainName;
|
|
2259
|
+
}
|
|
2260
|
+
|
|
2255
2261
|
return client.post(`${baseUrl}/token`, body, headers).then(response => Session.parse(response));
|
|
2256
2262
|
},
|
|
2257
2263
|
|
|
@@ -2264,6 +2270,7 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2264
2270
|
expiration ,
|
|
2265
2271
|
isMobile = false,
|
|
2266
2272
|
tenantId ,
|
|
2273
|
+
domainName ,
|
|
2267
2274
|
) => {
|
|
2268
2275
|
const body = {
|
|
2269
2276
|
backend: backend || DEFAULT_BACKEND_USER,
|
|
@@ -2273,9 +2280,14 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2273
2280
|
};
|
|
2274
2281
|
|
|
2275
2282
|
if (tenantId) {
|
|
2283
|
+
console.warn('Use of `tenantId` is deprecated when calling refreshToken() method, use `domainName` instead.');
|
|
2276
2284
|
body.tenant_id = tenantId;
|
|
2277
2285
|
}
|
|
2278
2286
|
|
|
2287
|
+
if (domainName) {
|
|
2288
|
+
body.domain_name = domainName;
|
|
2289
|
+
}
|
|
2290
|
+
|
|
2279
2291
|
const headers = {
|
|
2280
2292
|
'Content-Type': 'application/json',
|
|
2281
2293
|
...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),
|
|
@@ -5573,6 +5585,7 @@ class ApiClient {
|
|
|
5573
5585
|
|
|
5574
5586
|
|
|
5575
5587
|
|
|
5588
|
+
|
|
5576
5589
|
|
|
5577
5590
|
|
|
5578
5591
|
|
|
@@ -5614,6 +5627,7 @@ class ApiClient {
|
|
|
5614
5627
|
refreshToken: this.refreshToken,
|
|
5615
5628
|
refreshBackend: this.refreshBackend,
|
|
5616
5629
|
refreshTenantId: this.refreshTenantId,
|
|
5630
|
+
refreshDomainName: this.refreshDomainName,
|
|
5617
5631
|
refreshExpiration: this.refreshExpiration,
|
|
5618
5632
|
isMobile: this.isMobile,
|
|
5619
5633
|
});
|
|
@@ -5629,6 +5643,7 @@ class ApiClient {
|
|
|
5629
5643
|
this.refreshExpiration,
|
|
5630
5644
|
this.isMobile,
|
|
5631
5645
|
this.refreshTenantId,
|
|
5646
|
+
this.refreshDomainName,
|
|
5632
5647
|
);
|
|
5633
5648
|
|
|
5634
5649
|
logger$a.info('token refreshed', { token: session.token });
|
|
@@ -5682,9 +5697,14 @@ class ApiClient {
|
|
|
5682
5697
|
}
|
|
5683
5698
|
|
|
5684
5699
|
setRefreshTenantId(tenantId ) {
|
|
5700
|
+
console.warn('Use of `setRefreshTenantId` is deprecated, use `setRefreshDomainName` instead');
|
|
5685
5701
|
this.refreshTenantId = tenantId;
|
|
5686
5702
|
}
|
|
5687
5703
|
|
|
5704
|
+
setRefreshDomainName(domainName ) {
|
|
5705
|
+
this.refreshDomainName = domainName;
|
|
5706
|
+
}
|
|
5707
|
+
|
|
5688
5708
|
setIsMobile(isMobile ) {
|
|
5689
5709
|
this.isMobile = isMobile;
|
|
5690
5710
|
}
|
|
@@ -5709,6 +5729,7 @@ global.wazoClientId = global.wazoClientId || {};
|
|
|
5709
5729
|
global.wazoClientToken = global.wazoClientToken || {};
|
|
5710
5730
|
global.wazoRefreshToken = global.wazoRefreshToken || {};
|
|
5711
5731
|
global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
|
|
5732
|
+
global.wazoRefreshDomainName = global.wazoRefreshDomainName || {};
|
|
5712
5733
|
global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
|
|
5713
5734
|
global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
|
|
5714
5735
|
global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
|
|
@@ -5733,9 +5754,14 @@ const setRefreshToken = (newRefreshToken , forServer = null) =>
|
|
|
5733
5754
|
};
|
|
5734
5755
|
|
|
5735
5756
|
const setRefreshTenantId = (refreshTenantId , forServer = null) => {
|
|
5757
|
+
console.warn('Use of `setRefreshTenantId` is deprecated, please use `setRefreshDomainName` instead');
|
|
5736
5758
|
global.wazoRefreshTenantId[forServer] = refreshTenantId;
|
|
5737
5759
|
};
|
|
5738
5760
|
|
|
5761
|
+
const setRefreshDomainName = (refreshDomainName , forServer = null) => {
|
|
5762
|
+
global.wazoRefreshDomainName[forServer] = refreshDomainName;
|
|
5763
|
+
};
|
|
5764
|
+
|
|
5739
5765
|
const setOnRefreshToken = (onRefreshToken , forServer = null) => {
|
|
5740
5766
|
global.wazoOnRefreshToken[forServer] = onRefreshToken;
|
|
5741
5767
|
};
|
|
@@ -5754,6 +5780,7 @@ const setFetchOptions = (fetchOptions , forServer = null) => {
|
|
|
5754
5780
|
|
|
5755
5781
|
const fillClient = (apiClient ) => {
|
|
5756
5782
|
const { server, token, clientId } = apiClient.client;
|
|
5783
|
+
const tenantId = global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId;
|
|
5757
5784
|
|
|
5758
5785
|
// try with null server when dealing with non-related server info
|
|
5759
5786
|
apiClient.setToken(global.wazoClientToken[server] || global.wazoClientToken[null] || token);
|
|
@@ -5762,8 +5789,12 @@ const fillClient = (apiClient ) => {
|
|
|
5762
5789
|
|
|
5763
5790
|
apiClient.setRefreshToken(global.wazoRefreshToken[server] || global.wazoRefreshToken[null] || apiClient.refreshToken);
|
|
5764
5791
|
|
|
5765
|
-
|
|
5766
|
-
|
|
5792
|
+
if (tenantId) {
|
|
5793
|
+
apiClient.setRefreshTenantId(tenantId);
|
|
5794
|
+
}
|
|
5795
|
+
|
|
5796
|
+
apiClient.setRefreshDomainName(
|
|
5797
|
+
global.wazoRefreshDomainName[server] || global.wazoRefreshDomainName[null] || apiClient.refreshDomainName,
|
|
5767
5798
|
);
|
|
5768
5799
|
|
|
5769
5800
|
apiClient.setFetchOptions(global.wazoFetchOptions[server] || global.wazoFetchOptions[null] || apiClient.fetchOptions);
|
|
@@ -7419,7 +7450,7 @@ class WebRTCClient extends Emitter {
|
|
|
7419
7450
|
|
|
7420
7451
|
videoSender = transceiverIdx !== -1 ? transceivers[transceiverIdx].sender : null;
|
|
7421
7452
|
} else {
|
|
7422
|
-
videoSender = pc.getSenders().find(sender => sender.track === null);
|
|
7453
|
+
videoSender = pc && pc.getSenders && pc.getSenders().find(sender => sender.track === null);
|
|
7423
7454
|
}
|
|
7424
7455
|
|
|
7425
7456
|
if (!videoSender) {
|
|
@@ -7460,9 +7491,11 @@ class WebRTCClient extends Emitter {
|
|
|
7460
7491
|
const videoTracks = localStream.getVideoTracks();
|
|
7461
7492
|
|
|
7462
7493
|
// Remove video senders
|
|
7463
|
-
pc.getSenders
|
|
7464
|
-
|
|
7465
|
-
|
|
7494
|
+
if (pc.getSenders) {
|
|
7495
|
+
pc.getSenders().filter(sender => sender.track && sender.track.kind === 'video').forEach(videoSender => {
|
|
7496
|
+
videoSender.replaceTrack(null);
|
|
7497
|
+
});
|
|
7498
|
+
}
|
|
7466
7499
|
|
|
7467
7500
|
videoTracks.forEach(videoTrack => {
|
|
7468
7501
|
videoTrack.enabled = false;
|
|
@@ -7695,7 +7728,8 @@ class WebRTCClient extends Emitter {
|
|
|
7695
7728
|
const constraints = { audio: { deviceId: { exact: deviceId } } };
|
|
7696
7729
|
const stream = await navigator.mediaDevices.getUserMedia(constraints);
|
|
7697
7730
|
const audioTrack = stream.getAudioTracks()[0];
|
|
7698
|
-
const sender = pc && pc.getSenders
|
|
7731
|
+
const sender = pc && pc.getSenders
|
|
7732
|
+
&& pc.getSenders().find(s => audioTrack && s && s.track && s.track.kind === audioTrack.kind);
|
|
7699
7733
|
|
|
7700
7734
|
if (sender) {
|
|
7701
7735
|
if (sender.track) {
|
|
@@ -7758,10 +7792,11 @@ class WebRTCClient extends Emitter {
|
|
|
7758
7792
|
// $FlowFixMe
|
|
7759
7793
|
return navigator.mediaDevices.getUserMedia(constraints).then(async stream => {
|
|
7760
7794
|
const videoTrack = stream.getVideoTracks()[0];
|
|
7761
|
-
let sender = pc && pc.getSenders
|
|
7795
|
+
let sender = pc && pc.getSenders
|
|
7796
|
+
&& pc.getSenders().find(s => videoTrack && s && s.track && s.track.kind === videoTrack.kind);
|
|
7762
7797
|
let wasTrackEnabled = false;
|
|
7763
7798
|
if (!sender) {
|
|
7764
|
-
sender = pc && pc.getSenders().find(s => !s.track);
|
|
7799
|
+
sender = pc && pc.getSenders && pc.getSenders().find(s => !s.track);
|
|
7765
7800
|
}
|
|
7766
7801
|
|
|
7767
7802
|
if (sender) {
|
|
@@ -9295,7 +9330,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9295
9330
|
const screenTrack = screenShareStream.getVideoTracks()[0];
|
|
9296
9331
|
const sipSession = this.currentSipSession;
|
|
9297
9332
|
const pc = this.client.getPeerConnection(this.getSipSessionId(sipSession));
|
|
9298
|
-
const sender = pc && pc.getSenders().find(s => s && s.track && s.track.kind === 'video');
|
|
9333
|
+
const sender = pc && pc.getSenders && pc.getSenders().find(s => s && s.track && s.track.kind === 'video');
|
|
9299
9334
|
const localStream = this.client.getLocalStream(this.getSipSessionId(sipSession));
|
|
9300
9335
|
const videoTrack = localStream ? localStream.getTracks().find(track => track.kind === 'video') : null;
|
|
9301
9336
|
const hadVideo = !!videoTrack;
|
|
@@ -9377,7 +9412,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9377
9412
|
const screenTrack = screenStream.getVideoTracks()[0];
|
|
9378
9413
|
const sipSessionId = this.getSipSessionId(sipSession);
|
|
9379
9414
|
const pc = this.client.getPeerConnection(sipSessionId);
|
|
9380
|
-
const sender = pc && pc.getSenders().find(s => s && s.track && s.track.kind === 'video');
|
|
9415
|
+
const sender = pc && pc.getSenders && pc.getSenders().find(s => s && s.track && s.track.kind === 'video');
|
|
9381
9416
|
|
|
9382
9417
|
logger$8.info('WebRTC phone - on screensharing', {
|
|
9383
9418
|
hadVideo,
|
|
@@ -14009,6 +14044,7 @@ class Softphone {
|
|
|
14009
14044
|
wrapUpDuration,
|
|
14010
14045
|
enableAgent = true,
|
|
14011
14046
|
tenantId,
|
|
14047
|
+
domainName,
|
|
14012
14048
|
debug = false,
|
|
14013
14049
|
} = {}) {
|
|
14014
14050
|
this.url = url || 'https://softphone.wazo.io';
|
|
@@ -14033,8 +14069,12 @@ class Softphone {
|
|
|
14033
14069
|
config.port = port;
|
|
14034
14070
|
}
|
|
14035
14071
|
if (tenantId) {
|
|
14072
|
+
console.warn('Use of `tenantId` is deprecated when calling `Softphone.init()`, use `domainName` instead');
|
|
14036
14073
|
config.tenantId = tenantId;
|
|
14037
14074
|
}
|
|
14075
|
+
if (domainName) {
|
|
14076
|
+
config.domainName = domainName;
|
|
14077
|
+
}
|
|
14038
14078
|
if (wrapUpDuration) {
|
|
14039
14079
|
config.wrapUpDuration = wrapUpDuration;
|
|
14040
14080
|
}
|
|
@@ -14355,6 +14395,7 @@ const Wazo = {
|
|
|
14355
14395
|
CanceledCallError,
|
|
14356
14396
|
SFUNotAvailableError,
|
|
14357
14397
|
NoTenantIdError,
|
|
14398
|
+
NoDomainNameError,
|
|
14358
14399
|
};
|
|
14359
14400
|
|
|
14360
14401
|
if (window) {
|
|
@@ -14369,6 +14410,7 @@ if (global) {
|
|
|
14369
14410
|
class InvalidSubscription extends Error {}
|
|
14370
14411
|
class InvalidAuthorization extends Error {}
|
|
14371
14412
|
class NoTenantIdError extends Error {}
|
|
14413
|
+
class NoDomainNameError extends Error {}
|
|
14372
14414
|
|
|
14373
14415
|
const logger = IssueReporter$1.loggerFor('simple-auth');
|
|
14374
14416
|
|
|
@@ -14432,9 +14474,24 @@ class Auth {
|
|
|
14432
14474
|
setFetchOptions(options);
|
|
14433
14475
|
}
|
|
14434
14476
|
|
|
14435
|
-
async logIn(username , password , backend ,
|
|
14436
|
-
|
|
14437
|
-
|
|
14477
|
+
async logIn(username , password , backend , extra ) {
|
|
14478
|
+
let tenantId = null;
|
|
14479
|
+
let domainName = null;
|
|
14480
|
+
if (typeof extra === 'string') {
|
|
14481
|
+
tenantId = extra;
|
|
14482
|
+
}
|
|
14483
|
+
if (extra && typeof extra === 'object') {
|
|
14484
|
+
domainName = extra.domainName;
|
|
14485
|
+
}
|
|
14486
|
+
|
|
14487
|
+
if (backend && backend !== this.BACKEND_WAZO && !tenantId && !domainName) {
|
|
14488
|
+
if (!tenantId) {
|
|
14489
|
+
throw new NoTenantIdError('No tenant id');
|
|
14490
|
+
}
|
|
14491
|
+
|
|
14492
|
+
if (!domainName) {
|
|
14493
|
+
throw new NoDomainNameError('No domain name');
|
|
14494
|
+
}
|
|
14438
14495
|
}
|
|
14439
14496
|
|
|
14440
14497
|
this.authenticated = false;
|
|
@@ -14444,6 +14501,7 @@ class Auth {
|
|
|
14444
14501
|
password,
|
|
14445
14502
|
backend,
|
|
14446
14503
|
tenantId,
|
|
14504
|
+
domainName,
|
|
14447
14505
|
expiration: this.expiration,
|
|
14448
14506
|
mobile: this.mobile,
|
|
14449
14507
|
});
|
|
@@ -14452,7 +14510,13 @@ class Auth {
|
|
|
14452
14510
|
getApiClient().setRefreshBackend(backend);
|
|
14453
14511
|
}
|
|
14454
14512
|
|
|
14455
|
-
|
|
14513
|
+
if (tenantId) {
|
|
14514
|
+
getApiClient().setRefreshTenantId(tenantId);
|
|
14515
|
+
}
|
|
14516
|
+
|
|
14517
|
+
if (domainName) {
|
|
14518
|
+
getApiClient().setRefreshDomainName(domainName);
|
|
14519
|
+
}
|
|
14456
14520
|
|
|
14457
14521
|
return this._onAuthenticated(rawSession);
|
|
14458
14522
|
}
|
|
@@ -14551,11 +14615,18 @@ class Auth {
|
|
|
14551
14615
|
}
|
|
14552
14616
|
|
|
14553
14617
|
setRefreshTenantId(refreshTenantId ) {
|
|
14618
|
+
console.warn('Use of `setRefreshTenantId` is deprecated, use `setRefreshDomainName` instead.');
|
|
14554
14619
|
setRefreshTenantId(refreshTenantId);
|
|
14555
14620
|
|
|
14556
14621
|
getApiClient().setRefreshTenantId(refreshTenantId);
|
|
14557
14622
|
}
|
|
14558
14623
|
|
|
14624
|
+
setRefreshDomainName(domainName ) {
|
|
14625
|
+
setRefreshDomainName(domainName);
|
|
14626
|
+
|
|
14627
|
+
getApiClient().setRefreshDomainName(domainName);
|
|
14628
|
+
}
|
|
14629
|
+
|
|
14559
14630
|
forceRefreshToken() {
|
|
14560
14631
|
getApiClient().forceRefreshToken();
|
|
14561
14632
|
}
|
|
@@ -14666,4 +14737,4 @@ if (!global.wazoAuthInstance) {
|
|
|
14666
14737
|
var Auth$1 = global.wazoAuthInstance;
|
|
14667
14738
|
|
|
14668
14739
|
export default Auth$1;
|
|
14669
|
-
export { InvalidAuthorization, InvalidSubscription, NoTenantIdError };
|
|
14740
|
+
export { InvalidAuthorization, InvalidSubscription, NoDomainNameError, NoTenantIdError };
|
|
@@ -2229,6 +2229,7 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2229
2229
|
|
|
2230
2230
|
|
|
2231
2231
|
|
|
2232
|
+
|
|
2232
2233
|
) {
|
|
2233
2234
|
const body = {
|
|
2234
2235
|
backend: params.backend || DEFAULT_BACKEND_USER,
|
|
@@ -2249,9 +2250,14 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2249
2250
|
}
|
|
2250
2251
|
|
|
2251
2252
|
if (params.tenantId) {
|
|
2253
|
+
console.warn('Use of `tenantId` is deprecated when calling logIn() method, use `domainName` instead.');
|
|
2252
2254
|
body.tenant_id = params.tenantId;
|
|
2253
2255
|
}
|
|
2254
2256
|
|
|
2257
|
+
if (params.domainName) {
|
|
2258
|
+
body.domain_name = params.domainName;
|
|
2259
|
+
}
|
|
2260
|
+
|
|
2255
2261
|
return client.post(`${baseUrl}/token`, body, headers).then(response => Session.parse(response));
|
|
2256
2262
|
},
|
|
2257
2263
|
|
|
@@ -2264,6 +2270,7 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2264
2270
|
expiration ,
|
|
2265
2271
|
isMobile = false,
|
|
2266
2272
|
tenantId ,
|
|
2273
|
+
domainName ,
|
|
2267
2274
|
) => {
|
|
2268
2275
|
const body = {
|
|
2269
2276
|
backend: backend || DEFAULT_BACKEND_USER,
|
|
@@ -2273,9 +2280,14 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2273
2280
|
};
|
|
2274
2281
|
|
|
2275
2282
|
if (tenantId) {
|
|
2283
|
+
console.warn('Use of `tenantId` is deprecated when calling refreshToken() method, use `domainName` instead.');
|
|
2276
2284
|
body.tenant_id = tenantId;
|
|
2277
2285
|
}
|
|
2278
2286
|
|
|
2287
|
+
if (domainName) {
|
|
2288
|
+
body.domain_name = domainName;
|
|
2289
|
+
}
|
|
2290
|
+
|
|
2279
2291
|
const headers = {
|
|
2280
2292
|
'Content-Type': 'application/json',
|
|
2281
2293
|
...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),
|
|
@@ -5573,6 +5585,7 @@ class ApiClient {
|
|
|
5573
5585
|
|
|
5574
5586
|
|
|
5575
5587
|
|
|
5588
|
+
|
|
5576
5589
|
|
|
5577
5590
|
|
|
5578
5591
|
|
|
@@ -5614,6 +5627,7 @@ class ApiClient {
|
|
|
5614
5627
|
refreshToken: this.refreshToken,
|
|
5615
5628
|
refreshBackend: this.refreshBackend,
|
|
5616
5629
|
refreshTenantId: this.refreshTenantId,
|
|
5630
|
+
refreshDomainName: this.refreshDomainName,
|
|
5617
5631
|
refreshExpiration: this.refreshExpiration,
|
|
5618
5632
|
isMobile: this.isMobile,
|
|
5619
5633
|
});
|
|
@@ -5629,6 +5643,7 @@ class ApiClient {
|
|
|
5629
5643
|
this.refreshExpiration,
|
|
5630
5644
|
this.isMobile,
|
|
5631
5645
|
this.refreshTenantId,
|
|
5646
|
+
this.refreshDomainName,
|
|
5632
5647
|
);
|
|
5633
5648
|
|
|
5634
5649
|
logger$a.info('token refreshed', { token: session.token });
|
|
@@ -5682,9 +5697,14 @@ class ApiClient {
|
|
|
5682
5697
|
}
|
|
5683
5698
|
|
|
5684
5699
|
setRefreshTenantId(tenantId ) {
|
|
5700
|
+
console.warn('Use of `setRefreshTenantId` is deprecated, use `setRefreshDomainName` instead');
|
|
5685
5701
|
this.refreshTenantId = tenantId;
|
|
5686
5702
|
}
|
|
5687
5703
|
|
|
5704
|
+
setRefreshDomainName(domainName ) {
|
|
5705
|
+
this.refreshDomainName = domainName;
|
|
5706
|
+
}
|
|
5707
|
+
|
|
5688
5708
|
setIsMobile(isMobile ) {
|
|
5689
5709
|
this.isMobile = isMobile;
|
|
5690
5710
|
}
|
|
@@ -5709,6 +5729,7 @@ global.wazoClientId = global.wazoClientId || {};
|
|
|
5709
5729
|
global.wazoClientToken = global.wazoClientToken || {};
|
|
5710
5730
|
global.wazoRefreshToken = global.wazoRefreshToken || {};
|
|
5711
5731
|
global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
|
|
5732
|
+
global.wazoRefreshDomainName = global.wazoRefreshDomainName || {};
|
|
5712
5733
|
global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
|
|
5713
5734
|
global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
|
|
5714
5735
|
global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
|
|
@@ -5733,9 +5754,14 @@ const setRefreshToken = (newRefreshToken , forServer = null) =>
|
|
|
5733
5754
|
};
|
|
5734
5755
|
|
|
5735
5756
|
const setRefreshTenantId = (refreshTenantId , forServer = null) => {
|
|
5757
|
+
console.warn('Use of `setRefreshTenantId` is deprecated, please use `setRefreshDomainName` instead');
|
|
5736
5758
|
global.wazoRefreshTenantId[forServer] = refreshTenantId;
|
|
5737
5759
|
};
|
|
5738
5760
|
|
|
5761
|
+
const setRefreshDomainName = (refreshDomainName , forServer = null) => {
|
|
5762
|
+
global.wazoRefreshDomainName[forServer] = refreshDomainName;
|
|
5763
|
+
};
|
|
5764
|
+
|
|
5739
5765
|
const setOnRefreshToken = (onRefreshToken , forServer = null) => {
|
|
5740
5766
|
global.wazoOnRefreshToken[forServer] = onRefreshToken;
|
|
5741
5767
|
};
|
|
@@ -5754,6 +5780,7 @@ const setFetchOptions = (fetchOptions , forServer = null) => {
|
|
|
5754
5780
|
|
|
5755
5781
|
const fillClient = (apiClient ) => {
|
|
5756
5782
|
const { server, token, clientId } = apiClient.client;
|
|
5783
|
+
const tenantId = global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId;
|
|
5757
5784
|
|
|
5758
5785
|
// try with null server when dealing with non-related server info
|
|
5759
5786
|
apiClient.setToken(global.wazoClientToken[server] || global.wazoClientToken[null] || token);
|
|
@@ -5762,8 +5789,12 @@ const fillClient = (apiClient ) => {
|
|
|
5762
5789
|
|
|
5763
5790
|
apiClient.setRefreshToken(global.wazoRefreshToken[server] || global.wazoRefreshToken[null] || apiClient.refreshToken);
|
|
5764
5791
|
|
|
5765
|
-
|
|
5766
|
-
|
|
5792
|
+
if (tenantId) {
|
|
5793
|
+
apiClient.setRefreshTenantId(tenantId);
|
|
5794
|
+
}
|
|
5795
|
+
|
|
5796
|
+
apiClient.setRefreshDomainName(
|
|
5797
|
+
global.wazoRefreshDomainName[server] || global.wazoRefreshDomainName[null] || apiClient.refreshDomainName,
|
|
5767
5798
|
);
|
|
5768
5799
|
|
|
5769
5800
|
apiClient.setFetchOptions(global.wazoFetchOptions[server] || global.wazoFetchOptions[null] || apiClient.fetchOptions);
|
|
@@ -7419,7 +7450,7 @@ class WebRTCClient extends Emitter {
|
|
|
7419
7450
|
|
|
7420
7451
|
videoSender = transceiverIdx !== -1 ? transceivers[transceiverIdx].sender : null;
|
|
7421
7452
|
} else {
|
|
7422
|
-
videoSender = pc.getSenders().find(sender => sender.track === null);
|
|
7453
|
+
videoSender = pc && pc.getSenders && pc.getSenders().find(sender => sender.track === null);
|
|
7423
7454
|
}
|
|
7424
7455
|
|
|
7425
7456
|
if (!videoSender) {
|
|
@@ -7460,9 +7491,11 @@ class WebRTCClient extends Emitter {
|
|
|
7460
7491
|
const videoTracks = localStream.getVideoTracks();
|
|
7461
7492
|
|
|
7462
7493
|
// Remove video senders
|
|
7463
|
-
pc.getSenders
|
|
7464
|
-
|
|
7465
|
-
|
|
7494
|
+
if (pc.getSenders) {
|
|
7495
|
+
pc.getSenders().filter(sender => sender.track && sender.track.kind === 'video').forEach(videoSender => {
|
|
7496
|
+
videoSender.replaceTrack(null);
|
|
7497
|
+
});
|
|
7498
|
+
}
|
|
7466
7499
|
|
|
7467
7500
|
videoTracks.forEach(videoTrack => {
|
|
7468
7501
|
videoTrack.enabled = false;
|
|
@@ -7695,7 +7728,8 @@ class WebRTCClient extends Emitter {
|
|
|
7695
7728
|
const constraints = { audio: { deviceId: { exact: deviceId } } };
|
|
7696
7729
|
const stream = await navigator.mediaDevices.getUserMedia(constraints);
|
|
7697
7730
|
const audioTrack = stream.getAudioTracks()[0];
|
|
7698
|
-
const sender = pc && pc.getSenders
|
|
7731
|
+
const sender = pc && pc.getSenders
|
|
7732
|
+
&& pc.getSenders().find(s => audioTrack && s && s.track && s.track.kind === audioTrack.kind);
|
|
7699
7733
|
|
|
7700
7734
|
if (sender) {
|
|
7701
7735
|
if (sender.track) {
|
|
@@ -7758,10 +7792,11 @@ class WebRTCClient extends Emitter {
|
|
|
7758
7792
|
// $FlowFixMe
|
|
7759
7793
|
return navigator.mediaDevices.getUserMedia(constraints).then(async stream => {
|
|
7760
7794
|
const videoTrack = stream.getVideoTracks()[0];
|
|
7761
|
-
let sender = pc && pc.getSenders
|
|
7795
|
+
let sender = pc && pc.getSenders
|
|
7796
|
+
&& pc.getSenders().find(s => videoTrack && s && s.track && s.track.kind === videoTrack.kind);
|
|
7762
7797
|
let wasTrackEnabled = false;
|
|
7763
7798
|
if (!sender) {
|
|
7764
|
-
sender = pc && pc.getSenders().find(s => !s.track);
|
|
7799
|
+
sender = pc && pc.getSenders && pc.getSenders().find(s => !s.track);
|
|
7765
7800
|
}
|
|
7766
7801
|
|
|
7767
7802
|
if (sender) {
|
|
@@ -9295,7 +9330,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9295
9330
|
const screenTrack = screenShareStream.getVideoTracks()[0];
|
|
9296
9331
|
const sipSession = this.currentSipSession;
|
|
9297
9332
|
const pc = this.client.getPeerConnection(this.getSipSessionId(sipSession));
|
|
9298
|
-
const sender = pc && pc.getSenders().find(s => s && s.track && s.track.kind === 'video');
|
|
9333
|
+
const sender = pc && pc.getSenders && pc.getSenders().find(s => s && s.track && s.track.kind === 'video');
|
|
9299
9334
|
const localStream = this.client.getLocalStream(this.getSipSessionId(sipSession));
|
|
9300
9335
|
const videoTrack = localStream ? localStream.getTracks().find(track => track.kind === 'video') : null;
|
|
9301
9336
|
const hadVideo = !!videoTrack;
|
|
@@ -9377,7 +9412,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9377
9412
|
const screenTrack = screenStream.getVideoTracks()[0];
|
|
9378
9413
|
const sipSessionId = this.getSipSessionId(sipSession);
|
|
9379
9414
|
const pc = this.client.getPeerConnection(sipSessionId);
|
|
9380
|
-
const sender = pc && pc.getSenders().find(s => s && s.track && s.track.kind === 'video');
|
|
9415
|
+
const sender = pc && pc.getSenders && pc.getSenders().find(s => s && s.track && s.track.kind === 'video');
|
|
9381
9416
|
|
|
9382
9417
|
logger$8.info('WebRTC phone - on screensharing', {
|
|
9383
9418
|
hadVideo,
|
|
@@ -13992,6 +14027,7 @@ class Softphone {
|
|
|
13992
14027
|
wrapUpDuration,
|
|
13993
14028
|
enableAgent = true,
|
|
13994
14029
|
tenantId,
|
|
14030
|
+
domainName,
|
|
13995
14031
|
debug = false,
|
|
13996
14032
|
} = {}) {
|
|
13997
14033
|
this.url = url || 'https://softphone.wazo.io';
|
|
@@ -14016,8 +14052,12 @@ class Softphone {
|
|
|
14016
14052
|
config.port = port;
|
|
14017
14053
|
}
|
|
14018
14054
|
if (tenantId) {
|
|
14055
|
+
console.warn('Use of `tenantId` is deprecated when calling `Softphone.init()`, use `domainName` instead');
|
|
14019
14056
|
config.tenantId = tenantId;
|
|
14020
14057
|
}
|
|
14058
|
+
if (domainName) {
|
|
14059
|
+
config.domainName = domainName;
|
|
14060
|
+
}
|
|
14021
14061
|
if (wrapUpDuration) {
|
|
14022
14062
|
config.wrapUpDuration = wrapUpDuration;
|
|
14023
14063
|
}
|
|
@@ -14338,6 +14378,7 @@ const Wazo = {
|
|
|
14338
14378
|
CanceledCallError,
|
|
14339
14379
|
SFUNotAvailableError,
|
|
14340
14380
|
NoTenantIdError,
|
|
14381
|
+
NoDomainNameError,
|
|
14341
14382
|
};
|
|
14342
14383
|
|
|
14343
14384
|
if (window) {
|
|
@@ -14352,6 +14393,7 @@ if (global) {
|
|
|
14352
14393
|
class InvalidSubscription extends Error {}
|
|
14353
14394
|
class InvalidAuthorization extends Error {}
|
|
14354
14395
|
class NoTenantIdError extends Error {}
|
|
14396
|
+
class NoDomainNameError extends Error {}
|
|
14355
14397
|
|
|
14356
14398
|
const logger = IssueReporter$1.loggerFor('simple-auth');
|
|
14357
14399
|
|
|
@@ -14415,9 +14457,24 @@ class Auth {
|
|
|
14415
14457
|
setFetchOptions(options);
|
|
14416
14458
|
}
|
|
14417
14459
|
|
|
14418
|
-
async logIn(username , password , backend ,
|
|
14419
|
-
|
|
14420
|
-
|
|
14460
|
+
async logIn(username , password , backend , extra ) {
|
|
14461
|
+
let tenantId = null;
|
|
14462
|
+
let domainName = null;
|
|
14463
|
+
if (typeof extra === 'string') {
|
|
14464
|
+
tenantId = extra;
|
|
14465
|
+
}
|
|
14466
|
+
if (extra && typeof extra === 'object') {
|
|
14467
|
+
domainName = extra.domainName;
|
|
14468
|
+
}
|
|
14469
|
+
|
|
14470
|
+
if (backend && backend !== this.BACKEND_WAZO && !tenantId && !domainName) {
|
|
14471
|
+
if (!tenantId) {
|
|
14472
|
+
throw new NoTenantIdError('No tenant id');
|
|
14473
|
+
}
|
|
14474
|
+
|
|
14475
|
+
if (!domainName) {
|
|
14476
|
+
throw new NoDomainNameError('No domain name');
|
|
14477
|
+
}
|
|
14421
14478
|
}
|
|
14422
14479
|
|
|
14423
14480
|
this.authenticated = false;
|
|
@@ -14427,6 +14484,7 @@ class Auth {
|
|
|
14427
14484
|
password,
|
|
14428
14485
|
backend,
|
|
14429
14486
|
tenantId,
|
|
14487
|
+
domainName,
|
|
14430
14488
|
expiration: this.expiration,
|
|
14431
14489
|
mobile: this.mobile,
|
|
14432
14490
|
});
|
|
@@ -14435,7 +14493,13 @@ class Auth {
|
|
|
14435
14493
|
getApiClient().setRefreshBackend(backend);
|
|
14436
14494
|
}
|
|
14437
14495
|
|
|
14438
|
-
|
|
14496
|
+
if (tenantId) {
|
|
14497
|
+
getApiClient().setRefreshTenantId(tenantId);
|
|
14498
|
+
}
|
|
14499
|
+
|
|
14500
|
+
if (domainName) {
|
|
14501
|
+
getApiClient().setRefreshDomainName(domainName);
|
|
14502
|
+
}
|
|
14439
14503
|
|
|
14440
14504
|
return this._onAuthenticated(rawSession);
|
|
14441
14505
|
}
|
|
@@ -14534,11 +14598,18 @@ class Auth {
|
|
|
14534
14598
|
}
|
|
14535
14599
|
|
|
14536
14600
|
setRefreshTenantId(refreshTenantId ) {
|
|
14601
|
+
console.warn('Use of `setRefreshTenantId` is deprecated, use `setRefreshDomainName` instead.');
|
|
14537
14602
|
setRefreshTenantId(refreshTenantId);
|
|
14538
14603
|
|
|
14539
14604
|
getApiClient().setRefreshTenantId(refreshTenantId);
|
|
14540
14605
|
}
|
|
14541
14606
|
|
|
14607
|
+
setRefreshDomainName(domainName ) {
|
|
14608
|
+
setRefreshDomainName(domainName);
|
|
14609
|
+
|
|
14610
|
+
getApiClient().setRefreshDomainName(domainName);
|
|
14611
|
+
}
|
|
14612
|
+
|
|
14542
14613
|
forceRefreshToken() {
|
|
14543
14614
|
getApiClient().forceRefreshToken();
|
|
14544
14615
|
}
|