@wazo/sdk 0.38.8 → 0.38.11
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 +31 -6
- 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 +31 -6
- package/esm/checker/checks/aor.js +21 -0
- package/esm/checker/checks/api.js +21 -0
- package/esm/checker/checks/index.js +31 -6
- package/esm/checker/checks/webrtc-transport.js +31 -6
- package/esm/checker/checks/webrtc.js +31 -6
- 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 +4 -5
- package/esm/index.js +86 -17
- package/esm/service/CallApi.js +28 -2
- package/esm/service/getApiClient.js +34 -3
- package/esm/simple/Auth.js +87 -18
- package/esm/simple/Configuration.js +86 -17
- package/esm/simple/Directory.js +28 -2
- package/esm/simple/Phone.js +86 -17
- package/esm/simple/Softphone.js +5 -0
- package/esm/simple/index.js +86 -17
- package/esm/simple/room/LocalParticipant.js +86 -17
- package/esm/simple/room/Participant.js +86 -17
- package/esm/simple/room/RemoteParticipant.js +86 -17
- package/esm/simple/room/Room.js +86 -17
- package/esm/simple/room/SipRoom.js +86 -17
- package/esm/simple/room/Stream.js +86 -17
- package/esm/simple/room/__tests__/Participant.test.js +86 -17
- package/esm/simple/room/__tests__/RemoteParticipant.test.js +86 -17
- package/esm/simple/utils.js +86 -17
- package/esm/web-rtc-client.js +31 -6
- package/lib/__tests__/api-client.test.js +21 -0
- package/lib/__tests__/web-rtc-client.test.js +31 -6
- 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 +31 -6
- package/lib/checker/checks/aor.js +21 -0
- package/lib/checker/checks/api.js +21 -0
- package/lib/checker/checks/index.js +31 -6
- package/lib/checker/checks/webrtc-transport.js +31 -6
- package/lib/checker/checks/webrtc.js +31 -6
- 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 +4 -5
- package/lib/index.js +86 -17
- package/lib/service/CallApi.js +28 -2
- package/lib/service/getApiClient.js +34 -2
- package/lib/simple/Auth.js +87 -17
- package/lib/simple/Configuration.js +86 -17
- package/lib/simple/Directory.js +28 -2
- package/lib/simple/Phone.js +86 -17
- package/lib/simple/Softphone.js +5 -0
- package/lib/simple/index.js +86 -17
- package/lib/simple/room/LocalParticipant.js +86 -17
- package/lib/simple/room/Participant.js +86 -17
- package/lib/simple/room/RemoteParticipant.js +86 -17
- package/lib/simple/room/Room.js +86 -17
- package/lib/simple/room/SipRoom.js +86 -17
- package/lib/simple/room/Stream.js +86 -17
- package/lib/simple/room/__tests__/Participant.test.js +86 -17
- package/lib/simple/room/__tests__/RemoteParticipant.test.js +86 -17
- package/lib/simple/utils.js +86 -17
- package/lib/web-rtc-client.js +31 -6
- 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 +3 -5
- 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 +10 -6
package/lib/index.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' } : {}),
|
|
@@ -4134,6 +4146,7 @@ global.wazoClientId = global.wazoClientId || {};
|
|
|
4134
4146
|
global.wazoClientToken = global.wazoClientToken || {};
|
|
4135
4147
|
global.wazoRefreshToken = global.wazoRefreshToken || {};
|
|
4136
4148
|
global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
|
|
4149
|
+
global.wazoRefreshDomainName = global.wazoRefreshDomainName || {};
|
|
4137
4150
|
global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
|
|
4138
4151
|
global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
|
|
4139
4152
|
global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
|
|
@@ -4158,9 +4171,14 @@ const setRefreshToken = (newRefreshToken , forServer = null) =>
|
|
|
4158
4171
|
};
|
|
4159
4172
|
|
|
4160
4173
|
const setRefreshTenantId = (refreshTenantId , forServer = null) => {
|
|
4174
|
+
console.warn('Use of `setRefreshTenantId` is deprecated, please use `setRefreshDomainName` instead');
|
|
4161
4175
|
global.wazoRefreshTenantId[forServer] = refreshTenantId;
|
|
4162
4176
|
};
|
|
4163
4177
|
|
|
4178
|
+
const setRefreshDomainName = (refreshDomainName , forServer = null) => {
|
|
4179
|
+
global.wazoRefreshDomainName[forServer] = refreshDomainName;
|
|
4180
|
+
};
|
|
4181
|
+
|
|
4164
4182
|
const setOnRefreshToken = (onRefreshToken , forServer = null) => {
|
|
4165
4183
|
global.wazoOnRefreshToken[forServer] = onRefreshToken;
|
|
4166
4184
|
};
|
|
@@ -4179,6 +4197,7 @@ const setFetchOptions = (fetchOptions , forServer = null) => {
|
|
|
4179
4197
|
|
|
4180
4198
|
const fillClient = (apiClient ) => {
|
|
4181
4199
|
const { server, token, clientId } = apiClient.client;
|
|
4200
|
+
const tenantId = global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId;
|
|
4182
4201
|
|
|
4183
4202
|
// try with null server when dealing with non-related server info
|
|
4184
4203
|
apiClient.setToken(global.wazoClientToken[server] || global.wazoClientToken[null] || token);
|
|
@@ -4187,8 +4206,12 @@ const fillClient = (apiClient ) => {
|
|
|
4187
4206
|
|
|
4188
4207
|
apiClient.setRefreshToken(global.wazoRefreshToken[server] || global.wazoRefreshToken[null] || apiClient.refreshToken);
|
|
4189
4208
|
|
|
4190
|
-
|
|
4191
|
-
|
|
4209
|
+
if (tenantId) {
|
|
4210
|
+
apiClient.setRefreshTenantId(tenantId);
|
|
4211
|
+
}
|
|
4212
|
+
|
|
4213
|
+
apiClient.setRefreshDomainName(
|
|
4214
|
+
global.wazoRefreshDomainName[server] || global.wazoRefreshDomainName[null] || apiClient.refreshDomainName,
|
|
4192
4215
|
);
|
|
4193
4216
|
|
|
4194
4217
|
apiClient.setFetchOptions(global.wazoFetchOptions[server] || global.wazoFetchOptions[null] || apiClient.fetchOptions);
|
|
@@ -5686,6 +5709,7 @@ class ApiClient {
|
|
|
5686
5709
|
|
|
5687
5710
|
|
|
5688
5711
|
|
|
5712
|
+
|
|
5689
5713
|
|
|
5690
5714
|
|
|
5691
5715
|
|
|
@@ -5727,6 +5751,7 @@ class ApiClient {
|
|
|
5727
5751
|
refreshToken: this.refreshToken,
|
|
5728
5752
|
refreshBackend: this.refreshBackend,
|
|
5729
5753
|
refreshTenantId: this.refreshTenantId,
|
|
5754
|
+
refreshDomainName: this.refreshDomainName,
|
|
5730
5755
|
refreshExpiration: this.refreshExpiration,
|
|
5731
5756
|
isMobile: this.isMobile,
|
|
5732
5757
|
});
|
|
@@ -5742,6 +5767,7 @@ class ApiClient {
|
|
|
5742
5767
|
this.refreshExpiration,
|
|
5743
5768
|
this.isMobile,
|
|
5744
5769
|
this.refreshTenantId,
|
|
5770
|
+
this.refreshDomainName,
|
|
5745
5771
|
);
|
|
5746
5772
|
|
|
5747
5773
|
logger$a.info('token refreshed', { token: session.token });
|
|
@@ -5795,9 +5821,14 @@ class ApiClient {
|
|
|
5795
5821
|
}
|
|
5796
5822
|
|
|
5797
5823
|
setRefreshTenantId(tenantId ) {
|
|
5824
|
+
console.warn('Use of `setRefreshTenantId` is deprecated, use `setRefreshDomainName` instead');
|
|
5798
5825
|
this.refreshTenantId = tenantId;
|
|
5799
5826
|
}
|
|
5800
5827
|
|
|
5828
|
+
setRefreshDomainName(domainName ) {
|
|
5829
|
+
this.refreshDomainName = domainName;
|
|
5830
|
+
}
|
|
5831
|
+
|
|
5801
5832
|
setIsMobile(isMobile ) {
|
|
5802
5833
|
this.isMobile = isMobile;
|
|
5803
5834
|
}
|
|
@@ -7293,9 +7324,11 @@ class WebRTCClient extends Emitter {
|
|
|
7293
7324
|
const videoTracks = localStream.getVideoTracks();
|
|
7294
7325
|
|
|
7295
7326
|
// Remove video senders
|
|
7296
|
-
pc.getSenders
|
|
7297
|
-
|
|
7298
|
-
|
|
7327
|
+
if (pc.getSenders) {
|
|
7328
|
+
pc.getSenders().filter(sender => sender.track && sender.track.kind === 'video').forEach(videoSender => {
|
|
7329
|
+
videoSender.replaceTrack(null);
|
|
7330
|
+
});
|
|
7331
|
+
}
|
|
7299
7332
|
|
|
7300
7333
|
videoTracks.forEach(videoTrack => {
|
|
7301
7334
|
videoTrack.enabled = false;
|
|
@@ -7528,7 +7561,8 @@ class WebRTCClient extends Emitter {
|
|
|
7528
7561
|
const constraints = { audio: { deviceId: { exact: deviceId } } };
|
|
7529
7562
|
const stream = await navigator.mediaDevices.getUserMedia(constraints);
|
|
7530
7563
|
const audioTrack = stream.getAudioTracks()[0];
|
|
7531
|
-
const sender = pc && pc.getSenders
|
|
7564
|
+
const sender = pc && pc.getSenders
|
|
7565
|
+
&& pc.getSenders().find(s => audioTrack && s && s.track && s.track.kind === audioTrack.kind);
|
|
7532
7566
|
|
|
7533
7567
|
if (sender) {
|
|
7534
7568
|
if (sender.track) {
|
|
@@ -7591,10 +7625,11 @@ class WebRTCClient extends Emitter {
|
|
|
7591
7625
|
// $FlowFixMe
|
|
7592
7626
|
return navigator.mediaDevices.getUserMedia(constraints).then(async stream => {
|
|
7593
7627
|
const videoTrack = stream.getVideoTracks()[0];
|
|
7594
|
-
let sender = pc && pc.getSenders
|
|
7628
|
+
let sender = pc && pc.getSenders
|
|
7629
|
+
&& pc.getSenders().find(s => videoTrack && s && s.track && s.track.kind === videoTrack.kind);
|
|
7595
7630
|
let wasTrackEnabled = false;
|
|
7596
7631
|
if (!sender) {
|
|
7597
|
-
sender = pc && pc.getSenders().find(s => !s.track);
|
|
7632
|
+
sender = pc && pc.getSenders && pc.getSenders().find(s => !s.track);
|
|
7598
7633
|
}
|
|
7599
7634
|
|
|
7600
7635
|
if (sender) {
|
|
@@ -10032,7 +10067,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10032
10067
|
const screenTrack = screenShareStream.getVideoTracks()[0];
|
|
10033
10068
|
const sipSession = this.currentSipSession;
|
|
10034
10069
|
const pc = this.client.getPeerConnection(this.getSipSessionId(sipSession));
|
|
10035
|
-
const sender = pc && pc.getSenders().find(s => s && s.track && s.track.kind === 'video');
|
|
10070
|
+
const sender = pc && pc.getSenders && pc.getSenders().find(s => s && s.track && s.track.kind === 'video');
|
|
10036
10071
|
const localStream = this.client.getLocalStream(this.getSipSessionId(sipSession));
|
|
10037
10072
|
const videoTrack = localStream ? localStream.getTracks().find(track => track.kind === 'video') : null;
|
|
10038
10073
|
const hadVideo = !!videoTrack;
|
|
@@ -10070,9 +10105,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10070
10105
|
|
|
10071
10106
|
try {
|
|
10072
10107
|
if (this.currentScreenShare.stream) {
|
|
10073
|
-
this.currentScreenShare.stream.getTracks()
|
|
10074
|
-
.filter(track => track.kind === 'video')
|
|
10075
|
-
.forEach(track => track.stop());
|
|
10108
|
+
this.currentScreenShare.stream.getTracks().forEach(track => track.stop());
|
|
10076
10109
|
}
|
|
10077
10110
|
|
|
10078
10111
|
if (restoreLocalStream) {
|
|
@@ -10116,7 +10149,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10116
10149
|
const screenTrack = screenStream.getVideoTracks()[0];
|
|
10117
10150
|
const sipSessionId = this.getSipSessionId(sipSession);
|
|
10118
10151
|
const pc = this.client.getPeerConnection(sipSessionId);
|
|
10119
|
-
const sender = pc && pc.getSenders().find(s => s && s.track && s.track.kind === 'video');
|
|
10152
|
+
const sender = pc && pc.getSenders && pc.getSenders().find(s => s && s.track && s.track.kind === 'video');
|
|
10120
10153
|
|
|
10121
10154
|
logger$7.info('WebRTC phone - on screensharing', {
|
|
10122
10155
|
hadVideo,
|
|
@@ -11957,6 +11990,7 @@ const getCallableNumber = (number , country ) => {
|
|
|
11957
11990
|
class InvalidSubscription extends Error {}
|
|
11958
11991
|
class InvalidAuthorization extends Error {}
|
|
11959
11992
|
class NoTenantIdError extends Error {}
|
|
11993
|
+
class NoDomainNameError extends Error {}
|
|
11960
11994
|
|
|
11961
11995
|
const logger$5 = IssueReporter$1.loggerFor('simple-auth');
|
|
11962
11996
|
|
|
@@ -12020,9 +12054,24 @@ class Auth {
|
|
|
12020
12054
|
setFetchOptions(options);
|
|
12021
12055
|
}
|
|
12022
12056
|
|
|
12023
|
-
async logIn(username , password , backend ,
|
|
12024
|
-
|
|
12025
|
-
|
|
12057
|
+
async logIn(username , password , backend , extra ) {
|
|
12058
|
+
let tenantId = null;
|
|
12059
|
+
let domainName = null;
|
|
12060
|
+
if (typeof extra === 'string') {
|
|
12061
|
+
tenantId = extra;
|
|
12062
|
+
}
|
|
12063
|
+
if (extra && typeof extra === 'object') {
|
|
12064
|
+
domainName = extra.domainName;
|
|
12065
|
+
}
|
|
12066
|
+
|
|
12067
|
+
if (backend && backend !== this.BACKEND_WAZO && !tenantId && !domainName) {
|
|
12068
|
+
if (!tenantId) {
|
|
12069
|
+
throw new NoTenantIdError('No tenant id');
|
|
12070
|
+
}
|
|
12071
|
+
|
|
12072
|
+
if (!domainName) {
|
|
12073
|
+
throw new NoDomainNameError('No domain name');
|
|
12074
|
+
}
|
|
12026
12075
|
}
|
|
12027
12076
|
|
|
12028
12077
|
this.authenticated = false;
|
|
@@ -12032,6 +12081,7 @@ class Auth {
|
|
|
12032
12081
|
password,
|
|
12033
12082
|
backend,
|
|
12034
12083
|
tenantId,
|
|
12084
|
+
domainName,
|
|
12035
12085
|
expiration: this.expiration,
|
|
12036
12086
|
mobile: this.mobile,
|
|
12037
12087
|
});
|
|
@@ -12040,7 +12090,13 @@ class Auth {
|
|
|
12040
12090
|
getApiClient().setRefreshBackend(backend);
|
|
12041
12091
|
}
|
|
12042
12092
|
|
|
12043
|
-
|
|
12093
|
+
if (tenantId) {
|
|
12094
|
+
getApiClient().setRefreshTenantId(tenantId);
|
|
12095
|
+
}
|
|
12096
|
+
|
|
12097
|
+
if (domainName) {
|
|
12098
|
+
getApiClient().setRefreshDomainName(domainName);
|
|
12099
|
+
}
|
|
12044
12100
|
|
|
12045
12101
|
return this._onAuthenticated(rawSession);
|
|
12046
12102
|
}
|
|
@@ -12139,11 +12195,18 @@ class Auth {
|
|
|
12139
12195
|
}
|
|
12140
12196
|
|
|
12141
12197
|
setRefreshTenantId(refreshTenantId ) {
|
|
12198
|
+
console.warn('Use of `setRefreshTenantId` is deprecated, use `setRefreshDomainName` instead.');
|
|
12142
12199
|
setRefreshTenantId(refreshTenantId);
|
|
12143
12200
|
|
|
12144
12201
|
getApiClient().setRefreshTenantId(refreshTenantId);
|
|
12145
12202
|
}
|
|
12146
12203
|
|
|
12204
|
+
setRefreshDomainName(domainName ) {
|
|
12205
|
+
setRefreshDomainName(domainName);
|
|
12206
|
+
|
|
12207
|
+
getApiClient().setRefreshDomainName(domainName);
|
|
12208
|
+
}
|
|
12209
|
+
|
|
12147
12210
|
forceRefreshToken() {
|
|
12148
12211
|
getApiClient().forceRefreshToken();
|
|
12149
12212
|
}
|
|
@@ -14461,6 +14524,7 @@ class Softphone {
|
|
|
14461
14524
|
wrapUpDuration,
|
|
14462
14525
|
enableAgent = true,
|
|
14463
14526
|
tenantId,
|
|
14527
|
+
domainName,
|
|
14464
14528
|
debug = false,
|
|
14465
14529
|
} = {}) {
|
|
14466
14530
|
this.url = url || 'https://softphone.wazo.io';
|
|
@@ -14485,8 +14549,12 @@ class Softphone {
|
|
|
14485
14549
|
config.port = port;
|
|
14486
14550
|
}
|
|
14487
14551
|
if (tenantId) {
|
|
14552
|
+
console.warn('Use of `tenantId` is deprecated when calling `Softphone.init()`, use `domainName` instead');
|
|
14488
14553
|
config.tenantId = tenantId;
|
|
14489
14554
|
}
|
|
14555
|
+
if (domainName) {
|
|
14556
|
+
config.domainName = domainName;
|
|
14557
|
+
}
|
|
14490
14558
|
if (wrapUpDuration) {
|
|
14491
14559
|
config.wrapUpDuration = wrapUpDuration;
|
|
14492
14560
|
}
|
|
@@ -14807,6 +14875,7 @@ const Wazo = {
|
|
|
14807
14875
|
CanceledCallError,
|
|
14808
14876
|
SFUNotAvailableError,
|
|
14809
14877
|
NoTenantIdError,
|
|
14878
|
+
NoDomainNameError,
|
|
14810
14879
|
};
|
|
14811
14880
|
|
|
14812
14881
|
if (window) {
|
package/lib/service/CallApi.js
CHANGED
|
@@ -2761,6 +2761,7 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2761
2761
|
|
|
2762
2762
|
|
|
2763
2763
|
|
|
2764
|
+
|
|
2764
2765
|
) {
|
|
2765
2766
|
const body = {
|
|
2766
2767
|
backend: params.backend || DEFAULT_BACKEND_USER,
|
|
@@ -2781,9 +2782,14 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2781
2782
|
}
|
|
2782
2783
|
|
|
2783
2784
|
if (params.tenantId) {
|
|
2785
|
+
console.warn('Use of `tenantId` is deprecated when calling logIn() method, use `domainName` instead.');
|
|
2784
2786
|
body.tenant_id = params.tenantId;
|
|
2785
2787
|
}
|
|
2786
2788
|
|
|
2789
|
+
if (params.domainName) {
|
|
2790
|
+
body.domain_name = params.domainName;
|
|
2791
|
+
}
|
|
2792
|
+
|
|
2787
2793
|
return client.post(`${baseUrl}/token`, body, headers).then(response => Session.parse(response));
|
|
2788
2794
|
},
|
|
2789
2795
|
|
|
@@ -2796,6 +2802,7 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2796
2802
|
expiration ,
|
|
2797
2803
|
isMobile = false,
|
|
2798
2804
|
tenantId ,
|
|
2805
|
+
domainName ,
|
|
2799
2806
|
) => {
|
|
2800
2807
|
const body = {
|
|
2801
2808
|
backend: backend || DEFAULT_BACKEND_USER,
|
|
@@ -2805,9 +2812,14 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2805
2812
|
};
|
|
2806
2813
|
|
|
2807
2814
|
if (tenantId) {
|
|
2815
|
+
console.warn('Use of `tenantId` is deprecated when calling refreshToken() method, use `domainName` instead.');
|
|
2808
2816
|
body.tenant_id = tenantId;
|
|
2809
2817
|
}
|
|
2810
2818
|
|
|
2819
|
+
if (domainName) {
|
|
2820
|
+
body.domain_name = domainName;
|
|
2821
|
+
}
|
|
2822
|
+
|
|
2811
2823
|
const headers = {
|
|
2812
2824
|
'Content-Type': 'application/json',
|
|
2813
2825
|
...(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);
|
|
@@ -2217,6 +2217,7 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2217
2217
|
|
|
2218
2218
|
|
|
2219
2219
|
|
|
2220
|
+
|
|
2220
2221
|
) {
|
|
2221
2222
|
const body = {
|
|
2222
2223
|
backend: params.backend || DEFAULT_BACKEND_USER,
|
|
@@ -2237,9 +2238,14 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2237
2238
|
}
|
|
2238
2239
|
|
|
2239
2240
|
if (params.tenantId) {
|
|
2241
|
+
console.warn('Use of `tenantId` is deprecated when calling logIn() method, use `domainName` instead.');
|
|
2240
2242
|
body.tenant_id = params.tenantId;
|
|
2241
2243
|
}
|
|
2242
2244
|
|
|
2245
|
+
if (params.domainName) {
|
|
2246
|
+
body.domain_name = params.domainName;
|
|
2247
|
+
}
|
|
2248
|
+
|
|
2243
2249
|
return client.post(`${baseUrl}/token`, body, headers).then(response => Session.parse(response));
|
|
2244
2250
|
},
|
|
2245
2251
|
|
|
@@ -2252,6 +2258,7 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2252
2258
|
expiration ,
|
|
2253
2259
|
isMobile = false,
|
|
2254
2260
|
tenantId ,
|
|
2261
|
+
domainName ,
|
|
2255
2262
|
) => {
|
|
2256
2263
|
const body = {
|
|
2257
2264
|
backend: backend || DEFAULT_BACKEND_USER,
|
|
@@ -2261,9 +2268,14 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2261
2268
|
};
|
|
2262
2269
|
|
|
2263
2270
|
if (tenantId) {
|
|
2271
|
+
console.warn('Use of `tenantId` is deprecated when calling refreshToken() method, use `domainName` instead.');
|
|
2264
2272
|
body.tenant_id = tenantId;
|
|
2265
2273
|
}
|
|
2266
2274
|
|
|
2275
|
+
if (domainName) {
|
|
2276
|
+
body.domain_name = domainName;
|
|
2277
|
+
}
|
|
2278
|
+
|
|
2267
2279
|
const headers = {
|
|
2268
2280
|
'Content-Type': 'application/json',
|
|
2269
2281
|
...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),
|
|
@@ -4732,6 +4744,7 @@ class ApiClient {
|
|
|
4732
4744
|
|
|
4733
4745
|
|
|
4734
4746
|
|
|
4747
|
+
|
|
4735
4748
|
|
|
4736
4749
|
|
|
4737
4750
|
|
|
@@ -4773,6 +4786,7 @@ class ApiClient {
|
|
|
4773
4786
|
refreshToken: this.refreshToken,
|
|
4774
4787
|
refreshBackend: this.refreshBackend,
|
|
4775
4788
|
refreshTenantId: this.refreshTenantId,
|
|
4789
|
+
refreshDomainName: this.refreshDomainName,
|
|
4776
4790
|
refreshExpiration: this.refreshExpiration,
|
|
4777
4791
|
isMobile: this.isMobile,
|
|
4778
4792
|
});
|
|
@@ -4788,6 +4802,7 @@ class ApiClient {
|
|
|
4788
4802
|
this.refreshExpiration,
|
|
4789
4803
|
this.isMobile,
|
|
4790
4804
|
this.refreshTenantId,
|
|
4805
|
+
this.refreshDomainName,
|
|
4791
4806
|
);
|
|
4792
4807
|
|
|
4793
4808
|
logger.info('token refreshed', { token: session.token });
|
|
@@ -4841,9 +4856,14 @@ class ApiClient {
|
|
|
4841
4856
|
}
|
|
4842
4857
|
|
|
4843
4858
|
setRefreshTenantId(tenantId ) {
|
|
4859
|
+
console.warn('Use of `setRefreshTenantId` is deprecated, use `setRefreshDomainName` instead');
|
|
4844
4860
|
this.refreshTenantId = tenantId;
|
|
4845
4861
|
}
|
|
4846
4862
|
|
|
4863
|
+
setRefreshDomainName(domainName ) {
|
|
4864
|
+
this.refreshDomainName = domainName;
|
|
4865
|
+
}
|
|
4866
|
+
|
|
4847
4867
|
setIsMobile(isMobile ) {
|
|
4848
4868
|
this.isMobile = isMobile;
|
|
4849
4869
|
}
|
|
@@ -4868,6 +4888,7 @@ global.wazoClientId = global.wazoClientId || {};
|
|
|
4868
4888
|
global.wazoClientToken = global.wazoClientToken || {};
|
|
4869
4889
|
global.wazoRefreshToken = global.wazoRefreshToken || {};
|
|
4870
4890
|
global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
|
|
4891
|
+
global.wazoRefreshDomainName = global.wazoRefreshDomainName || {};
|
|
4871
4892
|
global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
|
|
4872
4893
|
global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
|
|
4873
4894
|
global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
|
|
@@ -4892,9 +4913,14 @@ const setRefreshToken = (newRefreshToken , forServer = null) =>
|
|
|
4892
4913
|
};
|
|
4893
4914
|
|
|
4894
4915
|
const setRefreshTenantId = (refreshTenantId , forServer = null) => {
|
|
4916
|
+
console.warn('Use of `setRefreshTenantId` is deprecated, please use `setRefreshDomainName` instead');
|
|
4895
4917
|
global.wazoRefreshTenantId[forServer] = refreshTenantId;
|
|
4896
4918
|
};
|
|
4897
4919
|
|
|
4920
|
+
const setRefreshDomainName = (refreshDomainName , forServer = null) => {
|
|
4921
|
+
global.wazoRefreshDomainName[forServer] = refreshDomainName;
|
|
4922
|
+
};
|
|
4923
|
+
|
|
4898
4924
|
const setOnRefreshToken = (onRefreshToken , forServer = null) => {
|
|
4899
4925
|
global.wazoOnRefreshToken[forServer] = onRefreshToken;
|
|
4900
4926
|
};
|
|
@@ -4921,6 +4947,7 @@ const setFetchOptions = (fetchOptions , forServer = null) => {
|
|
|
4921
4947
|
|
|
4922
4948
|
const fillClient = (apiClient ) => {
|
|
4923
4949
|
const { server, token, clientId } = apiClient.client;
|
|
4950
|
+
const tenantId = global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId;
|
|
4924
4951
|
|
|
4925
4952
|
// try with null server when dealing with non-related server info
|
|
4926
4953
|
apiClient.setToken(global.wazoClientToken[server] || global.wazoClientToken[null] || token);
|
|
@@ -4929,8 +4956,12 @@ const fillClient = (apiClient ) => {
|
|
|
4929
4956
|
|
|
4930
4957
|
apiClient.setRefreshToken(global.wazoRefreshToken[server] || global.wazoRefreshToken[null] || apiClient.refreshToken);
|
|
4931
4958
|
|
|
4932
|
-
|
|
4933
|
-
|
|
4959
|
+
if (tenantId) {
|
|
4960
|
+
apiClient.setRefreshTenantId(tenantId);
|
|
4961
|
+
}
|
|
4962
|
+
|
|
4963
|
+
apiClient.setRefreshDomainName(
|
|
4964
|
+
global.wazoRefreshDomainName[server] || global.wazoRefreshDomainName[null] || apiClient.refreshDomainName,
|
|
4934
4965
|
);
|
|
4935
4966
|
|
|
4936
4967
|
apiClient.setFetchOptions(global.wazoFetchOptions[server] || global.wazoFetchOptions[null] || apiClient.fetchOptions);
|
|
@@ -4976,6 +5007,7 @@ exports.setIsMobile = setIsMobile;
|
|
|
4976
5007
|
exports.setOnRefreshToken = setOnRefreshToken;
|
|
4977
5008
|
exports.setOnRefreshTokenError = setOnRefreshTokenError;
|
|
4978
5009
|
exports.setRefreshBackend = setRefreshBackend;
|
|
5010
|
+
exports.setRefreshDomainName = setRefreshDomainName;
|
|
4979
5011
|
exports.setRefreshExpiration = setRefreshExpiration;
|
|
4980
5012
|
exports.setRefreshTenantId = setRefreshTenantId;
|
|
4981
5013
|
exports.setRefreshToken = setRefreshToken;
|