@wazo/sdk 0.37.39 → 0.37.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/dist/wazo-sdk.js +2 -2
- package/esm/__tests__/api-client.test.js +33 -15
- package/esm/__tests__/web-rtc-client.test.js +39 -18
- package/esm/api/auth.js +4 -1
- package/esm/api/ctid-ng.js +2 -0
- package/esm/api-client.js +33 -15
- package/esm/checker/Checker.js +39 -18
- package/esm/checker/checks/aor.js +33 -15
- package/esm/checker/checks/api.js +33 -15
- package/esm/checker/checks/index.js +39 -18
- package/esm/checker/checks/webrtc-transport.js +39 -18
- package/esm/checker/checks/webrtc.js +39 -18
- package/esm/domain/AdHocAPIConference.js +42 -16
- package/esm/domain/Features.js +42 -16
- package/esm/domain/Phone/CTIPhone.js +42 -16
- package/esm/domain/Phone/WebRTCPhone.js +5 -3
- package/esm/index.js +77 -21
- package/esm/service/CallApi.js +42 -16
- package/esm/service/getApiClient.js +51 -17
- package/esm/simple/Auth.js +77 -21
- package/esm/simple/Configuration.js +77 -21
- package/esm/simple/Directory.js +42 -16
- package/esm/simple/Phone.js +77 -21
- package/esm/simple/index.js +77 -21
- package/esm/simple/room/LocalParticipant.js +77 -21
- package/esm/simple/room/Participant.js +77 -21
- package/esm/simple/room/RemoteParticipant.js +77 -21
- package/esm/simple/room/Room.js +77 -21
- package/esm/simple/room/SipRoom.js +77 -21
- package/esm/simple/room/Stream.js +77 -21
- package/esm/simple/room/__tests__/RemoteParticipant.test.js +77 -21
- package/esm/simple/utils.js +77 -21
- package/esm/web-rtc-client.js +39 -18
- package/lib/__tests__/api-client.test.js +33 -15
- package/lib/__tests__/web-rtc-client.test.js +39 -18
- package/lib/api/auth.js +4 -1
- package/lib/api/ctid-ng.js +2 -0
- package/lib/api-client.js +33 -15
- package/lib/checker/Checker.js +39 -18
- package/lib/checker/checks/aor.js +33 -15
- package/lib/checker/checks/api.js +33 -15
- package/lib/checker/checks/index.js +39 -18
- package/lib/checker/checks/webrtc-transport.js +39 -18
- package/lib/checker/checks/webrtc.js +39 -18
- package/lib/domain/AdHocAPIConference.js +42 -16
- package/lib/domain/Features.js +42 -16
- package/lib/domain/Phone/CTIPhone.js +42 -16
- package/lib/domain/Phone/WebRTCPhone.js +5 -3
- package/lib/index.js +77 -21
- package/lib/service/CallApi.js +42 -16
- package/lib/service/getApiClient.js +52 -16
- package/lib/simple/Auth.js +77 -21
- package/lib/simple/Configuration.js +77 -21
- package/lib/simple/Directory.js +42 -16
- package/lib/simple/Phone.js +77 -21
- package/lib/simple/index.js +77 -21
- package/lib/simple/room/LocalParticipant.js +77 -21
- package/lib/simple/room/Participant.js +77 -21
- package/lib/simple/room/RemoteParticipant.js +77 -21
- package/lib/simple/room/Room.js +77 -21
- package/lib/simple/room/SipRoom.js +77 -21
- package/lib/simple/room/Stream.js +77 -21
- package/lib/simple/room/__tests__/RemoteParticipant.test.js +77 -21
- package/lib/simple/utils.js +77 -21
- package/lib/web-rtc-client.js +39 -18
- package/package.json +1 -1
- package/src/api/auth.js +4 -1
- package/src/api-client.js +26 -13
- package/src/domain/Phone/WebRTCPhone.js +3 -3
- package/src/service/getApiClient.js +19 -1
- package/src/simple/Auth.js +21 -0
- package/src/web-rtc-client.js +7 -4
package/lib/web-rtc-client.js
CHANGED
|
@@ -2804,9 +2804,12 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2804
2804
|
expiration: expiration || DETAULT_EXPIRATION,
|
|
2805
2805
|
refresh_token: refreshToken,
|
|
2806
2806
|
client_id: client.clientId,
|
|
2807
|
-
tenant_id: tenantId,
|
|
2808
2807
|
};
|
|
2809
2808
|
|
|
2809
|
+
if (tenantId) {
|
|
2810
|
+
body.tenant_id = tenantId;
|
|
2811
|
+
}
|
|
2812
|
+
|
|
2810
2813
|
const headers = {
|
|
2811
2814
|
'Content-Type': 'application/json',
|
|
2812
2815
|
...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),
|
|
@@ -4094,7 +4097,9 @@ global.wazoClients = global.wazoClients || {};
|
|
|
4094
4097
|
global.wazoClientId = global.wazoClientId || {};
|
|
4095
4098
|
global.wazoClientToken = global.wazoClientToken || {};
|
|
4096
4099
|
global.wazoRefreshToken = global.wazoRefreshToken || {};
|
|
4100
|
+
global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
|
|
4097
4101
|
global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
|
|
4102
|
+
global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
|
|
4098
4103
|
global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
|
|
4099
4104
|
global.wazoRefreshBackend = global.wazoRefreshBackend || {};
|
|
4100
4105
|
global.wazoIsMobile = global.wazoIsMobile || {};
|
|
@@ -5140,6 +5145,7 @@ class ApiClient {
|
|
|
5140
5145
|
|
|
5141
5146
|
|
|
5142
5147
|
|
|
5148
|
+
|
|
5143
5149
|
|
|
5144
5150
|
|
|
5145
5151
|
|
|
@@ -5192,23 +5198,31 @@ class ApiClient {
|
|
|
5192
5198
|
return null;
|
|
5193
5199
|
}
|
|
5194
5200
|
|
|
5195
|
-
|
|
5196
|
-
this.refreshToken
|
|
5197
|
-
|
|
5198
|
-
|
|
5199
|
-
|
|
5200
|
-
|
|
5201
|
-
|
|
5202
|
-
|
|
5203
|
-
|
|
5201
|
+
try {
|
|
5202
|
+
const session = await this.auth.refreshToken(
|
|
5203
|
+
this.refreshToken,
|
|
5204
|
+
this.refreshBackend,
|
|
5205
|
+
this.refreshExpiration,
|
|
5206
|
+
this.isMobile,
|
|
5207
|
+
this.refreshTenantId,
|
|
5208
|
+
);
|
|
5209
|
+
|
|
5210
|
+
logger$1.info('token refreshed', { token: session.token });
|
|
5211
|
+
|
|
5212
|
+
if (this.onRefreshToken) {
|
|
5213
|
+
this.onRefreshToken(session.token, session);
|
|
5214
|
+
}
|
|
5204
5215
|
|
|
5205
|
-
|
|
5206
|
-
this.onRefreshToken(session.token, session);
|
|
5207
|
-
}
|
|
5216
|
+
this.setToken(session.token);
|
|
5208
5217
|
|
|
5209
|
-
|
|
5218
|
+
return session.token;
|
|
5219
|
+
} catch (error) {
|
|
5220
|
+
logger$1.error('token refresh, error', error);
|
|
5210
5221
|
|
|
5211
|
-
|
|
5222
|
+
if (this.onRefreshTokenError) {
|
|
5223
|
+
this.onRefreshTokenError(error);
|
|
5224
|
+
}
|
|
5225
|
+
}
|
|
5212
5226
|
}
|
|
5213
5227
|
|
|
5214
5228
|
setToken(token ) {
|
|
@@ -5231,6 +5245,10 @@ class ApiClient {
|
|
|
5231
5245
|
this.onRefreshToken = onRefreshToken;
|
|
5232
5246
|
}
|
|
5233
5247
|
|
|
5248
|
+
setOnRefreshTokenError(callback ) {
|
|
5249
|
+
this.onRefreshTokenError = callback;
|
|
5250
|
+
}
|
|
5251
|
+
|
|
5234
5252
|
setRefreshExpiration(refreshExpiration ) {
|
|
5235
5253
|
this.refreshExpiration = refreshExpiration;
|
|
5236
5254
|
}
|
|
@@ -7411,11 +7429,14 @@ class WebRTCClient extends Emitter {
|
|
|
7411
7429
|
}
|
|
7412
7430
|
|
|
7413
7431
|
async _disconnectTransport(force = false) {
|
|
7414
|
-
if (force) {
|
|
7432
|
+
if (force && this.userAgent && this.userAgent.transport) {
|
|
7415
7433
|
// Bypass sip.js state machine that prevent to close WS with the state `Connecting`
|
|
7416
7434
|
this.userAgent.transport.disconnectResolve = () => {};
|
|
7417
|
-
|
|
7418
|
-
this.userAgent.transport._ws
|
|
7435
|
+
|
|
7436
|
+
if (this.userAgent.transport._ws) {
|
|
7437
|
+
this.userAgent.transport._ws.close(1000);
|
|
7438
|
+
}
|
|
7439
|
+
|
|
7419
7440
|
return;
|
|
7420
7441
|
}
|
|
7421
7442
|
|
package/package.json
CHANGED
package/src/api/auth.js
CHANGED
|
@@ -74,9 +74,12 @@ export default (client: ApiRequester, baseUrl: string) => ({
|
|
|
74
74
|
expiration: expiration || DETAULT_EXPIRATION,
|
|
75
75
|
refresh_token: refreshToken,
|
|
76
76
|
client_id: client.clientId,
|
|
77
|
-
tenant_id: tenantId,
|
|
78
77
|
};
|
|
79
78
|
|
|
79
|
+
if (tenantId) {
|
|
80
|
+
body.tenant_id = tenantId;
|
|
81
|
+
}
|
|
82
|
+
|
|
80
83
|
const headers: Object = {
|
|
81
84
|
'Content-Type': 'application/json',
|
|
82
85
|
...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),
|
package/src/api-client.js
CHANGED
|
@@ -53,6 +53,7 @@ export default class ApiClient {
|
|
|
53
53
|
|
|
54
54
|
refreshToken: ?string;
|
|
55
55
|
onRefreshToken: ?Function;
|
|
56
|
+
onRefreshTokenError: ?Function;
|
|
56
57
|
refreshExpiration: ?number;
|
|
57
58
|
refreshBackend: ?string;
|
|
58
59
|
refreshTenantId: ?string;
|
|
@@ -105,23 +106,31 @@ export default class ApiClient {
|
|
|
105
106
|
return null;
|
|
106
107
|
}
|
|
107
108
|
|
|
108
|
-
|
|
109
|
-
this.refreshToken
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
109
|
+
try {
|
|
110
|
+
const session = await this.auth.refreshToken(
|
|
111
|
+
this.refreshToken,
|
|
112
|
+
this.refreshBackend,
|
|
113
|
+
this.refreshExpiration,
|
|
114
|
+
this.isMobile,
|
|
115
|
+
this.refreshTenantId,
|
|
116
|
+
);
|
|
115
117
|
|
|
116
|
-
|
|
118
|
+
logger.info('token refreshed', { token: session.token });
|
|
117
119
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
120
|
+
if (this.onRefreshToken) {
|
|
121
|
+
this.onRefreshToken(session.token, session);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
this.setToken(session.token);
|
|
121
125
|
|
|
122
|
-
|
|
126
|
+
return session.token;
|
|
127
|
+
} catch (error) {
|
|
128
|
+
logger.error('token refresh, error', error);
|
|
123
129
|
|
|
124
|
-
|
|
130
|
+
if (this.onRefreshTokenError) {
|
|
131
|
+
this.onRefreshTokenError(error);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
125
134
|
}
|
|
126
135
|
|
|
127
136
|
setToken(token: string) {
|
|
@@ -144,6 +153,10 @@ export default class ApiClient {
|
|
|
144
153
|
this.onRefreshToken = onRefreshToken;
|
|
145
154
|
}
|
|
146
155
|
|
|
156
|
+
setOnRefreshTokenError(callback: Function) {
|
|
157
|
+
this.onRefreshTokenError = callback;
|
|
158
|
+
}
|
|
159
|
+
|
|
147
160
|
setRefreshExpiration(refreshExpiration: number) {
|
|
148
161
|
this.refreshExpiration = refreshExpiration;
|
|
149
162
|
}
|
|
@@ -543,7 +543,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
543
543
|
// When stopping screenshare and we had video before that, we have to re-upgrade
|
|
544
544
|
// When upgrading directly to screenshare (eg: we don't have a videoLocalStream to replace)
|
|
545
545
|
// We have to downgrade to audio.
|
|
546
|
-
const screenshareStopped = this.currentScreenShare.
|
|
546
|
+
const screenshareStopped = this.currentScreenShare.hadVideo;
|
|
547
547
|
const constraints = { audio: false, video: screenshareStopped };
|
|
548
548
|
|
|
549
549
|
// We have to remove the video sender to be able to re-upgrade to video in `sendReinvite` below
|
|
@@ -987,7 +987,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
987
987
|
|
|
988
988
|
logger.info('WebRTC hold sip session', { sipId: sipSession.id, hasVideo });
|
|
989
989
|
|
|
990
|
-
// Stop
|
|
990
|
+
// Stop screenshare if needed
|
|
991
991
|
if (this.currentScreenShare && this.currentScreenShare.sipSessionId === sessionId) {
|
|
992
992
|
this.lastScreenShare = this.currentScreenShare;
|
|
993
993
|
await this.stopScreenSharing(false, callSession);
|
|
@@ -1751,7 +1751,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1751
1751
|
endTime: fromSession ? fromSession.endTime : null,
|
|
1752
1752
|
answered: state === SessionState.Established,
|
|
1753
1753
|
paused: this.client.isCallHeld(sipSession),
|
|
1754
|
-
isCaller: 'incoming' in extra ? !extra.incoming : false,
|
|
1754
|
+
isCaller: fromSession ? fromSession.isCaller : ('incoming' in extra ? !extra.incoming : false),
|
|
1755
1755
|
cameraEnabled: fromSession ? fromSession.isCameraEnabled() : this.client.hasVideo(sessionId),
|
|
1756
1756
|
number,
|
|
1757
1757
|
ringing: false,
|
|
@@ -10,7 +10,9 @@ global.wazoClients = global.wazoClients || {};
|
|
|
10
10
|
global.wazoClientId = global.wazoClientId || {};
|
|
11
11
|
global.wazoClientToken = global.wazoClientToken || {};
|
|
12
12
|
global.wazoRefreshToken = global.wazoRefreshToken || {};
|
|
13
|
+
global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
|
|
13
14
|
global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
|
|
15
|
+
global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
|
|
14
16
|
global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
|
|
15
17
|
global.wazoRefreshBackend = global.wazoRefreshBackend || {};
|
|
16
18
|
global.wazoIsMobile = global.wazoIsMobile || {};
|
|
@@ -32,10 +34,18 @@ export const setRefreshToken = (newRefreshToken: ?string, forServer: ?string = n
|
|
|
32
34
|
global.wazoRefreshToken[forServer] = newRefreshToken;
|
|
33
35
|
};
|
|
34
36
|
|
|
37
|
+
export const setRefreshTenantId = (refreshTenantId: ?string, forServer: ?string = null) => {
|
|
38
|
+
global.wazoRefreshTenantId[forServer] = refreshTenantId;
|
|
39
|
+
};
|
|
40
|
+
|
|
35
41
|
export const setOnRefreshToken = (onRefreshToken: Function, forServer: ?string = null) => {
|
|
36
42
|
global.wazoOnRefreshToken[forServer] = onRefreshToken;
|
|
37
43
|
};
|
|
38
44
|
|
|
45
|
+
export const setOnRefreshTokenError = (callback: Function, forServer: ?string = null) => {
|
|
46
|
+
global.wazoOnRefreshTokenError[forServer] = callback;
|
|
47
|
+
};
|
|
48
|
+
|
|
39
49
|
export const setRefreshExpiration = (refreshExpiration: number, forServer: ?string = null) => {
|
|
40
50
|
global.wazoRefreshExpiration[forServer] = refreshExpiration;
|
|
41
51
|
};
|
|
@@ -62,12 +72,20 @@ const fillClient = (apiClient: WazoApiClient) => {
|
|
|
62
72
|
|
|
63
73
|
apiClient.setRefreshToken(global.wazoRefreshToken[server] || global.wazoRefreshToken[null] || apiClient.refreshToken);
|
|
64
74
|
|
|
75
|
+
apiClient.setRefreshTenantId(
|
|
76
|
+
global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId,
|
|
77
|
+
);
|
|
78
|
+
|
|
65
79
|
apiClient.setFetchOptions(global.wazoFetchOptions[server] || global.wazoFetchOptions[null] || apiClient.fetchOptions);
|
|
66
80
|
|
|
67
81
|
apiClient.setOnRefreshToken(
|
|
68
82
|
global.wazoOnRefreshToken[server] || global.wazoOnRefreshToken[null] || apiClient.onRefreshToken,
|
|
69
83
|
);
|
|
70
84
|
|
|
85
|
+
apiClient.setOnRefreshTokenError(
|
|
86
|
+
global.wazoOnRefreshTokenError[server] || global.wazoOnRefreshTokenError[null] || apiClient.onRefreshTokenError,
|
|
87
|
+
);
|
|
88
|
+
|
|
71
89
|
apiClient.setRefreshExpiration(
|
|
72
90
|
global.wazoRefreshExpiration[server] || global.wazoRefreshExpiration[null] || apiClient.refreshExpiration,
|
|
73
91
|
);
|
|
@@ -81,7 +99,7 @@ const fillClient = (apiClient: WazoApiClient) => {
|
|
|
81
99
|
return apiClient;
|
|
82
100
|
};
|
|
83
101
|
|
|
84
|
-
export default (forServer: ?string): WazoApiClient => {
|
|
102
|
+
export default (forServer: ?string = null): WazoApiClient => {
|
|
85
103
|
const server: string = forServer || global.wazoCurrentServer || '';
|
|
86
104
|
if (server in global.wazoClients) {
|
|
87
105
|
return fillClient(global.wazoClients[server]);
|
package/src/simple/Auth.js
CHANGED
|
@@ -10,6 +10,8 @@ import getApiClient, {
|
|
|
10
10
|
setRefreshExpiration,
|
|
11
11
|
setOnRefreshToken,
|
|
12
12
|
setFetchOptions,
|
|
13
|
+
setRefreshTenantId,
|
|
14
|
+
setOnRefreshTokenError,
|
|
13
15
|
} from '../service/getApiClient';
|
|
14
16
|
import IssueReporter from '../service/IssueReporter';
|
|
15
17
|
|
|
@@ -29,6 +31,7 @@ class Auth {
|
|
|
29
31
|
host: ?string;
|
|
30
32
|
session: ?Session;
|
|
31
33
|
onRefreshTokenCallback: ?Function;
|
|
34
|
+
onRefreshTokenCallbackError: ?Function;
|
|
32
35
|
authenticated: boolean;
|
|
33
36
|
mobile: boolean;
|
|
34
37
|
BACKEND_WAZO: string;
|
|
@@ -66,6 +69,14 @@ class Auth {
|
|
|
66
69
|
this.onRefreshTokenCallback(token, session);
|
|
67
70
|
}
|
|
68
71
|
});
|
|
72
|
+
|
|
73
|
+
setOnRefreshTokenError(error => {
|
|
74
|
+
logger.error('on refresh token error', error);
|
|
75
|
+
|
|
76
|
+
if (this.onRefreshTokenCallbackError) {
|
|
77
|
+
this.onRefreshTokenCallbackError(error);
|
|
78
|
+
}
|
|
79
|
+
});
|
|
69
80
|
}
|
|
70
81
|
|
|
71
82
|
setFetchOptions(options: Object) {
|
|
@@ -154,6 +165,10 @@ class Auth {
|
|
|
154
165
|
this.onRefreshTokenCallback = callback;
|
|
155
166
|
}
|
|
156
167
|
|
|
168
|
+
setOnRefreshTokenError(callback: Function) {
|
|
169
|
+
this.onRefreshTokenCallbackError = callback;
|
|
170
|
+
}
|
|
171
|
+
|
|
157
172
|
checkAuthorizations(session: Session, authorizationName: ?string) {
|
|
158
173
|
if (!authorizationName) {
|
|
159
174
|
return;
|
|
@@ -186,6 +201,12 @@ class Auth {
|
|
|
186
201
|
setRefreshToken(refreshToken);
|
|
187
202
|
}
|
|
188
203
|
|
|
204
|
+
setRefreshTenantId(refreshTenantId: string) {
|
|
205
|
+
setRefreshTenantId(refreshTenantId);
|
|
206
|
+
|
|
207
|
+
getApiClient().setRefreshTenantId(refreshTenantId);
|
|
208
|
+
}
|
|
209
|
+
|
|
189
210
|
forceRefreshToken() {
|
|
190
211
|
getApiClient().forceRefreshToken();
|
|
191
212
|
}
|
package/src/web-rtc-client.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @flow
|
|
2
|
-
/* eslint-disable class-methods-use-this, no-param-reassign, max-classes-per-file */
|
|
2
|
+
/* eslint-disable class-methods-use-this, no-param-reassign, max-classes-per-file, no-underscore-dangle */
|
|
3
3
|
/* global window, document, navigator */
|
|
4
4
|
import 'webrtc-adapter';
|
|
5
5
|
import type InviterInviteOptions from 'sip.js/lib/api/inviter-invite-options';
|
|
@@ -2084,11 +2084,14 @@ export default class WebRTCClient extends Emitter {
|
|
|
2084
2084
|
}
|
|
2085
2085
|
|
|
2086
2086
|
async _disconnectTransport(force: boolean = false) {
|
|
2087
|
-
if (force) {
|
|
2087
|
+
if (force && this.userAgent && this.userAgent.transport) {
|
|
2088
2088
|
// Bypass sip.js state machine that prevent to close WS with the state `Connecting`
|
|
2089
2089
|
this.userAgent.transport.disconnectResolve = () => {};
|
|
2090
|
-
|
|
2091
|
-
this.userAgent.transport._ws
|
|
2090
|
+
|
|
2091
|
+
if (this.userAgent.transport._ws) {
|
|
2092
|
+
this.userAgent.transport._ws.close(1000);
|
|
2093
|
+
}
|
|
2094
|
+
|
|
2092
2095
|
return;
|
|
2093
2096
|
}
|
|
2094
2097
|
|