@wazo/sdk 0.37.36 → 0.37.39
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 +7 -2
- package/dist/wazo-sdk.js +2 -2
- package/esm/__tests__/api-client.test.js +9 -0
- package/esm/__tests__/web-rtc-client.test.js +9 -0
- package/esm/api/auth.js +4 -1
- package/esm/api-client.js +9 -0
- package/esm/checker/Checker.js +9 -0
- package/esm/checker/checks/aor.js +9 -0
- package/esm/checker/checks/api.js +9 -0
- package/esm/checker/checks/index.js +9 -0
- package/esm/checker/checks/webrtc-transport.js +9 -0
- package/esm/checker/checks/webrtc.js +9 -0
- package/esm/domain/AdHocAPIConference.js +14 -5
- package/esm/domain/Features.js +9 -0
- package/esm/domain/Phone/CTIPhone.js +9 -0
- package/esm/domain/SwitchboardCall.js +5 -5
- package/esm/index.js +40 -11
- package/esm/service/CallApi.js +9 -0
- package/esm/service/getApiClient.js +9 -0
- package/esm/simple/Auth.js +41 -12
- package/esm/simple/Configuration.js +40 -11
- package/esm/simple/Directory.js +9 -0
- package/esm/simple/Phone.js +40 -11
- package/esm/simple/index.js +40 -11
- package/esm/simple/room/LocalParticipant.js +40 -11
- package/esm/simple/room/Participant.js +40 -11
- package/esm/simple/room/RemoteParticipant.js +40 -11
- package/esm/simple/room/Room.js +40 -11
- package/esm/simple/room/SipRoom.js +40 -11
- package/esm/simple/room/Stream.js +40 -11
- package/esm/simple/room/__tests__/RemoteParticipant.test.js +40 -11
- package/esm/simple/utils.js +40 -11
- package/esm/web-rtc-client.js +9 -0
- package/lib/__tests__/api-client.test.js +9 -0
- package/lib/__tests__/web-rtc-client.test.js +9 -0
- package/lib/api/auth.js +5 -0
- package/lib/api-client.js +9 -0
- package/lib/checker/Checker.js +9 -0
- package/lib/checker/checks/aor.js +9 -0
- package/lib/checker/checks/api.js +9 -0
- package/lib/checker/checks/index.js +9 -0
- package/lib/checker/checks/webrtc-transport.js +9 -0
- package/lib/checker/checks/webrtc.js +9 -0
- package/lib/domain/AdHocAPIConference.js +14 -5
- package/lib/domain/Features.js +9 -0
- package/lib/domain/Phone/CTIPhone.js +9 -0
- package/lib/domain/SwitchboardCall.js +5 -5
- package/lib/index.js +40 -11
- package/lib/service/CallApi.js +9 -0
- package/lib/service/getApiClient.js +9 -0
- package/lib/simple/Auth.js +41 -11
- package/lib/simple/Configuration.js +40 -11
- package/lib/simple/Directory.js +9 -0
- package/lib/simple/Phone.js +40 -11
- package/lib/simple/index.js +40 -11
- package/lib/simple/room/LocalParticipant.js +40 -11
- package/lib/simple/room/Participant.js +40 -11
- package/lib/simple/room/RemoteParticipant.js +40 -11
- package/lib/simple/room/Room.js +40 -11
- package/lib/simple/room/SipRoom.js +40 -11
- package/lib/simple/room/Stream.js +40 -11
- package/lib/simple/room/__tests__/RemoteParticipant.test.js +40 -11
- package/lib/simple/utils.js +40 -11
- package/lib/web-rtc-client.js +9 -0
- package/package.json +1 -1
- package/src/api/auth.js +4 -1
- package/src/api-client.js +7 -0
- package/src/domain/AdHocAPIConference.js +5 -5
- package/src/domain/SwitchboardCall.js +5 -5
- package/src/simple/Auth.js +20 -2
- package/src/simple/index.js +2 -1
package/lib/simple/utils.js
CHANGED
|
@@ -2220,6 +2220,7 @@ class ApiRequester {
|
|
|
2220
2220
|
/* */
|
|
2221
2221
|
|
|
2222
2222
|
const DEFAULT_BACKEND_USER = 'wazo_user';
|
|
2223
|
+
const BACKEND_LDAP_USER = 'ldap_user';
|
|
2223
2224
|
const DETAULT_EXPIRATION = 3600;
|
|
2224
2225
|
|
|
2225
2226
|
var authMethods = (client , baseUrl ) => ({
|
|
@@ -2269,12 +2270,14 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2269
2270
|
backend ,
|
|
2270
2271
|
expiration ,
|
|
2271
2272
|
isMobile = false,
|
|
2273
|
+
tenantId ,
|
|
2272
2274
|
) => {
|
|
2273
2275
|
const body = {
|
|
2274
2276
|
backend: backend || DEFAULT_BACKEND_USER,
|
|
2275
2277
|
expiration: expiration || DETAULT_EXPIRATION,
|
|
2276
2278
|
refresh_token: refreshToken,
|
|
2277
2279
|
client_id: client.clientId,
|
|
2280
|
+
tenant_id: tenantId,
|
|
2278
2281
|
};
|
|
2279
2282
|
|
|
2280
2283
|
const headers = {
|
|
@@ -5426,6 +5429,7 @@ class ApiClient {
|
|
|
5426
5429
|
|
|
5427
5430
|
|
|
5428
5431
|
|
|
5432
|
+
|
|
5429
5433
|
|
|
5430
5434
|
|
|
5431
5435
|
|
|
@@ -5466,6 +5470,7 @@ class ApiClient {
|
|
|
5466
5470
|
logger$a.info('refresh token callback called', {
|
|
5467
5471
|
refreshToken: this.refreshToken,
|
|
5468
5472
|
refreshBackend: this.refreshBackend,
|
|
5473
|
+
refreshTenantId: this.refreshTenantId,
|
|
5469
5474
|
refreshExpiration: this.refreshExpiration,
|
|
5470
5475
|
isMobile: this.isMobile,
|
|
5471
5476
|
});
|
|
@@ -5479,6 +5484,7 @@ class ApiClient {
|
|
|
5479
5484
|
this.refreshBackend,
|
|
5480
5485
|
this.refreshExpiration,
|
|
5481
5486
|
this.isMobile,
|
|
5487
|
+
this.refreshTenantId,
|
|
5482
5488
|
);
|
|
5483
5489
|
|
|
5484
5490
|
logger$a.info('token refreshed', { token: session.token });
|
|
@@ -5520,6 +5526,10 @@ class ApiClient {
|
|
|
5520
5526
|
this.refreshBackend = refreshBackend;
|
|
5521
5527
|
}
|
|
5522
5528
|
|
|
5529
|
+
setRefreshTenantId(tenantId ) {
|
|
5530
|
+
this.refreshTenantId = tenantId;
|
|
5531
|
+
}
|
|
5532
|
+
|
|
5523
5533
|
setIsMobile(isMobile ) {
|
|
5524
5534
|
this.isMobile = isMobile;
|
|
5525
5535
|
}
|
|
@@ -5621,6 +5631,7 @@ var getApiClient = (forServer ) => {
|
|
|
5621
5631
|
|
|
5622
5632
|
class InvalidSubscription extends Error {}
|
|
5623
5633
|
class InvalidAuthorization extends Error {}
|
|
5634
|
+
class NoTenantIdError extends Error {}
|
|
5624
5635
|
|
|
5625
5636
|
const logger$9 = IssueReporter$1.loggerFor('simple-auth');
|
|
5626
5637
|
|
|
@@ -5634,11 +5645,15 @@ class Auth {
|
|
|
5634
5645
|
|
|
5635
5646
|
|
|
5636
5647
|
|
|
5648
|
+
|
|
5649
|
+
|
|
5637
5650
|
|
|
5638
5651
|
constructor() {
|
|
5639
5652
|
this.expiration = DETAULT_EXPIRATION;
|
|
5640
5653
|
this.authenticated = false;
|
|
5641
5654
|
this.minSubscriptionType = null;
|
|
5655
|
+
this.BACKEND_WAZO = DEFAULT_BACKEND_USER;
|
|
5656
|
+
this.BACKEND_LDAP = BACKEND_LDAP_USER;
|
|
5642
5657
|
}
|
|
5643
5658
|
|
|
5644
5659
|
init(clientId ,
|
|
@@ -5671,15 +5686,28 @@ class Auth {
|
|
|
5671
5686
|
setFetchOptions(options);
|
|
5672
5687
|
}
|
|
5673
5688
|
|
|
5674
|
-
async logIn(username , password ) {
|
|
5689
|
+
async logIn(username , password , backend , tenantId ) {
|
|
5690
|
+
if (backend && backend !== this.BACKEND_WAZO && !tenantId) {
|
|
5691
|
+
throw new NoTenantIdError('No tenant id');
|
|
5692
|
+
}
|
|
5693
|
+
|
|
5675
5694
|
this.authenticated = false;
|
|
5676
5695
|
this.session = null;
|
|
5677
5696
|
const rawSession = await getApiClient().auth.logIn({
|
|
5678
5697
|
username,
|
|
5679
5698
|
password,
|
|
5699
|
+
backend,
|
|
5700
|
+
tenantId,
|
|
5680
5701
|
expiration: this.expiration,
|
|
5681
5702
|
mobile: this.mobile,
|
|
5682
5703
|
});
|
|
5704
|
+
|
|
5705
|
+
if (backend) {
|
|
5706
|
+
getApiClient().setRefreshBackend(backend);
|
|
5707
|
+
}
|
|
5708
|
+
|
|
5709
|
+
getApiClient().setRefreshTenantId(tenantId);
|
|
5710
|
+
|
|
5683
5711
|
return this._onAuthenticated(rawSession);
|
|
5684
5712
|
}
|
|
5685
5713
|
|
|
@@ -5906,7 +5934,7 @@ var Auth$1 = global.wazoAuthInstance;
|
|
|
5906
5934
|
|
|
5907
5935
|
|
|
5908
5936
|
|
|
5909
|
-
|
|
5937
|
+
|
|
5910
5938
|
|
|
5911
5939
|
|
|
5912
5940
|
|
|
@@ -5926,7 +5954,7 @@ class AdHocAPIConference {
|
|
|
5926
5954
|
|
|
5927
5955
|
|
|
5928
5956
|
|
|
5929
|
-
|
|
5957
|
+
|
|
5930
5958
|
|
|
5931
5959
|
|
|
5932
5960
|
|
|
@@ -5938,7 +5966,7 @@ class AdHocAPIConference {
|
|
|
5938
5966
|
participants,
|
|
5939
5967
|
started,
|
|
5940
5968
|
finished,
|
|
5941
|
-
|
|
5969
|
+
answerTime,
|
|
5942
5970
|
conferenceId,
|
|
5943
5971
|
muted,
|
|
5944
5972
|
paused,
|
|
@@ -5948,7 +5976,7 @@ class AdHocAPIConference {
|
|
|
5948
5976
|
this.participants = participants || {};
|
|
5949
5977
|
this.started = started || false;
|
|
5950
5978
|
this.finished = finished || false;
|
|
5951
|
-
this.
|
|
5979
|
+
this.answerTime = answerTime;
|
|
5952
5980
|
this.conferenceId = conferenceId || '';
|
|
5953
5981
|
this.muted = muted || false;
|
|
5954
5982
|
this.paused = paused || false;
|
|
@@ -5961,7 +5989,7 @@ class AdHocAPIConference {
|
|
|
5961
5989
|
async start() {
|
|
5962
5990
|
this.started = true;
|
|
5963
5991
|
// $FlowFixMe
|
|
5964
|
-
this.
|
|
5992
|
+
this.answerTime = Object.values(this.participants).length ? Object.values(this.participants)[0].answerTime : null;
|
|
5965
5993
|
|
|
5966
5994
|
const participantIds = Object.keys(this.participants);
|
|
5967
5995
|
const conference = await getApiClient().calld.createAdHocConference(this.host.callId, participantIds);
|
|
@@ -13239,7 +13267,7 @@ class Room {
|
|
|
13239
13267
|
|
|
13240
13268
|
|
|
13241
13269
|
|
|
13242
|
-
|
|
13270
|
+
|
|
13243
13271
|
|
|
13244
13272
|
|
|
13245
13273
|
|
|
@@ -13265,7 +13293,7 @@ class SwitchboardCall {
|
|
|
13265
13293
|
|
|
13266
13294
|
|
|
13267
13295
|
|
|
13268
|
-
|
|
13296
|
+
|
|
13269
13297
|
|
|
13270
13298
|
|
|
13271
13299
|
|
|
@@ -13279,7 +13307,7 @@ class SwitchboardCall {
|
|
|
13279
13307
|
callerIdName: plain.caller_id_name || null,
|
|
13280
13308
|
callerIdNumber: plain.caller_id_number || null,
|
|
13281
13309
|
participantId: plain.participantId || null,
|
|
13282
|
-
|
|
13310
|
+
answerTime: plain.startTime,
|
|
13283
13311
|
state: plain.state,
|
|
13284
13312
|
switchboardName: plain.switchboardName,
|
|
13285
13313
|
switchboardUuid: plain.switchboardUuid,
|
|
@@ -13292,7 +13320,7 @@ class SwitchboardCall {
|
|
|
13292
13320
|
callerIdName,
|
|
13293
13321
|
callerIdNumber,
|
|
13294
13322
|
participantId,
|
|
13295
|
-
|
|
13323
|
+
answerTime,
|
|
13296
13324
|
state,
|
|
13297
13325
|
switchboardName,
|
|
13298
13326
|
switchboardUuid,
|
|
@@ -13302,7 +13330,7 @@ class SwitchboardCall {
|
|
|
13302
13330
|
this.callerIdName = callerIdName;
|
|
13303
13331
|
this.callerIdNumber = callerIdNumber;
|
|
13304
13332
|
this.participantId = participantId;
|
|
13305
|
-
this.
|
|
13333
|
+
this.answerTime = answerTime;
|
|
13306
13334
|
this.state = state;
|
|
13307
13335
|
this.switchboardName = switchboardName;
|
|
13308
13336
|
this.switchboardUuid = switchboardUuid;
|
|
@@ -13939,6 +13967,7 @@ const Wazo = {
|
|
|
13939
13967
|
InvalidAuthorization,
|
|
13940
13968
|
CanceledCallError,
|
|
13941
13969
|
SFUNotAvailableError,
|
|
13970
|
+
NoTenantIdError,
|
|
13942
13971
|
};
|
|
13943
13972
|
|
|
13944
13973
|
if (window) {
|
package/lib/web-rtc-client.js
CHANGED
|
@@ -2797,12 +2797,14 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2797
2797
|
backend ,
|
|
2798
2798
|
expiration ,
|
|
2799
2799
|
isMobile = false,
|
|
2800
|
+
tenantId ,
|
|
2800
2801
|
) => {
|
|
2801
2802
|
const body = {
|
|
2802
2803
|
backend: backend || DEFAULT_BACKEND_USER,
|
|
2803
2804
|
expiration: expiration || DETAULT_EXPIRATION,
|
|
2804
2805
|
refresh_token: refreshToken,
|
|
2805
2806
|
client_id: client.clientId,
|
|
2807
|
+
tenant_id: tenantId,
|
|
2806
2808
|
};
|
|
2807
2809
|
|
|
2808
2810
|
const headers = {
|
|
@@ -5140,6 +5142,7 @@ class ApiClient {
|
|
|
5140
5142
|
|
|
5141
5143
|
|
|
5142
5144
|
|
|
5145
|
+
|
|
5143
5146
|
|
|
5144
5147
|
|
|
5145
5148
|
|
|
@@ -5180,6 +5183,7 @@ class ApiClient {
|
|
|
5180
5183
|
logger$1.info('refresh token callback called', {
|
|
5181
5184
|
refreshToken: this.refreshToken,
|
|
5182
5185
|
refreshBackend: this.refreshBackend,
|
|
5186
|
+
refreshTenantId: this.refreshTenantId,
|
|
5183
5187
|
refreshExpiration: this.refreshExpiration,
|
|
5184
5188
|
isMobile: this.isMobile,
|
|
5185
5189
|
});
|
|
@@ -5193,6 +5197,7 @@ class ApiClient {
|
|
|
5193
5197
|
this.refreshBackend,
|
|
5194
5198
|
this.refreshExpiration,
|
|
5195
5199
|
this.isMobile,
|
|
5200
|
+
this.refreshTenantId,
|
|
5196
5201
|
);
|
|
5197
5202
|
|
|
5198
5203
|
logger$1.info('token refreshed', { token: session.token });
|
|
@@ -5234,6 +5239,10 @@ class ApiClient {
|
|
|
5234
5239
|
this.refreshBackend = refreshBackend;
|
|
5235
5240
|
}
|
|
5236
5241
|
|
|
5242
|
+
setRefreshTenantId(tenantId ) {
|
|
5243
|
+
this.refreshTenantId = tenantId;
|
|
5244
|
+
}
|
|
5245
|
+
|
|
5237
5246
|
setIsMobile(isMobile ) {
|
|
5238
5247
|
this.isMobile = isMobile;
|
|
5239
5248
|
}
|
package/package.json
CHANGED
package/src/api/auth.js
CHANGED
|
@@ -16,7 +16,8 @@ import type {
|
|
|
16
16
|
} from '../domain/types';
|
|
17
17
|
import Session from '../domain/Session';
|
|
18
18
|
|
|
19
|
-
const DEFAULT_BACKEND_USER = 'wazo_user';
|
|
19
|
+
export const DEFAULT_BACKEND_USER = 'wazo_user';
|
|
20
|
+
export const BACKEND_LDAP_USER = 'ldap_user';
|
|
20
21
|
export const DETAULT_EXPIRATION = 3600;
|
|
21
22
|
|
|
22
23
|
export default (client: ApiRequester, baseUrl: string) => ({
|
|
@@ -66,12 +67,14 @@ export default (client: ApiRequester, baseUrl: string) => ({
|
|
|
66
67
|
backend: string,
|
|
67
68
|
expiration: number,
|
|
68
69
|
isMobile: boolean = false,
|
|
70
|
+
tenantId: ?string,
|
|
69
71
|
): Promise<?Session> => {
|
|
70
72
|
const body: Object = {
|
|
71
73
|
backend: backend || DEFAULT_BACKEND_USER,
|
|
72
74
|
expiration: expiration || DETAULT_EXPIRATION,
|
|
73
75
|
refresh_token: refreshToken,
|
|
74
76
|
client_id: client.clientId,
|
|
77
|
+
tenant_id: tenantId,
|
|
75
78
|
};
|
|
76
79
|
|
|
77
80
|
const headers: Object = {
|
package/src/api-client.js
CHANGED
|
@@ -55,6 +55,7 @@ export default class ApiClient {
|
|
|
55
55
|
onRefreshToken: ?Function;
|
|
56
56
|
refreshExpiration: ?number;
|
|
57
57
|
refreshBackend: ?string;
|
|
58
|
+
refreshTenantId: ?string;
|
|
58
59
|
isMobile: boolean;
|
|
59
60
|
fetchOptions: Object;
|
|
60
61
|
|
|
@@ -95,6 +96,7 @@ export default class ApiClient {
|
|
|
95
96
|
logger.info('refresh token callback called', {
|
|
96
97
|
refreshToken: this.refreshToken,
|
|
97
98
|
refreshBackend: this.refreshBackend,
|
|
99
|
+
refreshTenantId: this.refreshTenantId,
|
|
98
100
|
refreshExpiration: this.refreshExpiration,
|
|
99
101
|
isMobile: this.isMobile,
|
|
100
102
|
});
|
|
@@ -108,6 +110,7 @@ export default class ApiClient {
|
|
|
108
110
|
this.refreshBackend,
|
|
109
111
|
this.refreshExpiration,
|
|
110
112
|
this.isMobile,
|
|
113
|
+
this.refreshTenantId,
|
|
111
114
|
);
|
|
112
115
|
|
|
113
116
|
logger.info('token refreshed', { token: session.token });
|
|
@@ -149,6 +152,10 @@ export default class ApiClient {
|
|
|
149
152
|
this.refreshBackend = refreshBackend;
|
|
150
153
|
}
|
|
151
154
|
|
|
155
|
+
setRefreshTenantId(tenantId: ?string) {
|
|
156
|
+
this.refreshTenantId = tenantId;
|
|
157
|
+
}
|
|
158
|
+
|
|
152
159
|
setIsMobile(isMobile: boolean) {
|
|
153
160
|
this.isMobile = isMobile;
|
|
154
161
|
}
|
|
@@ -27,7 +27,7 @@ export type ConferenceArguments = {
|
|
|
27
27
|
finished?: boolean,
|
|
28
28
|
participants: {[string]: CallSession};
|
|
29
29
|
started?: boolean,
|
|
30
|
-
|
|
30
|
+
answerTime?: ?number,
|
|
31
31
|
conferenceId?: ?string,
|
|
32
32
|
muted?: boolean,
|
|
33
33
|
paused?: boolean,
|
|
@@ -47,7 +47,7 @@ export default class AdHocAPIConference {
|
|
|
47
47
|
|
|
48
48
|
conferenceId: string;
|
|
49
49
|
|
|
50
|
-
|
|
50
|
+
answerTime: ?number;
|
|
51
51
|
|
|
52
52
|
muted: boolean;
|
|
53
53
|
|
|
@@ -59,7 +59,7 @@ export default class AdHocAPIConference {
|
|
|
59
59
|
participants,
|
|
60
60
|
started,
|
|
61
61
|
finished,
|
|
62
|
-
|
|
62
|
+
answerTime,
|
|
63
63
|
conferenceId,
|
|
64
64
|
muted,
|
|
65
65
|
paused,
|
|
@@ -69,7 +69,7 @@ export default class AdHocAPIConference {
|
|
|
69
69
|
this.participants = participants || {};
|
|
70
70
|
this.started = started || false;
|
|
71
71
|
this.finished = finished || false;
|
|
72
|
-
this.
|
|
72
|
+
this.answerTime = answerTime;
|
|
73
73
|
this.conferenceId = conferenceId || '';
|
|
74
74
|
this.muted = muted || false;
|
|
75
75
|
this.paused = paused || false;
|
|
@@ -82,7 +82,7 @@ export default class AdHocAPIConference {
|
|
|
82
82
|
async start() {
|
|
83
83
|
this.started = true;
|
|
84
84
|
// $FlowFixMe
|
|
85
|
-
this.
|
|
85
|
+
this.answerTime = Object.values(this.participants).length ? Object.values(this.participants)[0].answerTime : null;
|
|
86
86
|
|
|
87
87
|
const participantIds = Object.keys(this.participants);
|
|
88
88
|
const conference = await getApiClient().calld.createAdHocConference(this.host.callId, participantIds);
|
|
@@ -28,7 +28,7 @@ type SwitchboardCallArguments = {
|
|
|
28
28
|
callSession: ?CallSession,
|
|
29
29
|
callerIdName: ?string,
|
|
30
30
|
callerIdNumber: ?string,
|
|
31
|
-
|
|
31
|
+
answerTime: ?Date,
|
|
32
32
|
participantId: ?string,
|
|
33
33
|
state: string,
|
|
34
34
|
switchboardName: string,
|
|
@@ -54,7 +54,7 @@ class SwitchboardCall {
|
|
|
54
54
|
callSession: ?CallSession;
|
|
55
55
|
callerIdName: ?string;
|
|
56
56
|
callerIdNumber: ?string;
|
|
57
|
-
|
|
57
|
+
answerTime: ?Date;
|
|
58
58
|
participantId: ?string;
|
|
59
59
|
state: string;
|
|
60
60
|
switchboardName: string;
|
|
@@ -68,7 +68,7 @@ class SwitchboardCall {
|
|
|
68
68
|
callerIdName: plain.caller_id_name || null,
|
|
69
69
|
callerIdNumber: plain.caller_id_number || null,
|
|
70
70
|
participantId: plain.participantId || null,
|
|
71
|
-
|
|
71
|
+
answerTime: plain.startTime,
|
|
72
72
|
state: plain.state,
|
|
73
73
|
switchboardName: plain.switchboardName,
|
|
74
74
|
switchboardUuid: plain.switchboardUuid,
|
|
@@ -81,7 +81,7 @@ class SwitchboardCall {
|
|
|
81
81
|
callerIdName,
|
|
82
82
|
callerIdNumber,
|
|
83
83
|
participantId,
|
|
84
|
-
|
|
84
|
+
answerTime,
|
|
85
85
|
state,
|
|
86
86
|
switchboardName,
|
|
87
87
|
switchboardUuid,
|
|
@@ -91,7 +91,7 @@ class SwitchboardCall {
|
|
|
91
91
|
this.callerIdName = callerIdName;
|
|
92
92
|
this.callerIdNumber = callerIdNumber;
|
|
93
93
|
this.participantId = participantId;
|
|
94
|
-
this.
|
|
94
|
+
this.answerTime = answerTime;
|
|
95
95
|
this.state = state;
|
|
96
96
|
this.switchboardName = switchboardName;
|
|
97
97
|
this.switchboardUuid = switchboardUuid;
|
package/src/simple/Auth.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @flow
|
|
2
2
|
/* eslint-disable max-classes-per-file */
|
|
3
3
|
import Session from '../domain/Session';
|
|
4
|
-
import { DETAULT_EXPIRATION } from '../api/auth';
|
|
4
|
+
import { BACKEND_LDAP_USER, DEFAULT_BACKEND_USER, DETAULT_EXPIRATION } from '../api/auth';
|
|
5
5
|
import getApiClient, {
|
|
6
6
|
setCurrentServer,
|
|
7
7
|
setApiToken,
|
|
@@ -17,6 +17,7 @@ import Wazo from './index';
|
|
|
17
17
|
|
|
18
18
|
export class InvalidSubscription extends Error {}
|
|
19
19
|
export class InvalidAuthorization extends Error {}
|
|
20
|
+
export class NoTenantIdError extends Error {}
|
|
20
21
|
|
|
21
22
|
const logger = IssueReporter.loggerFor('simple-auth');
|
|
22
23
|
|
|
@@ -30,11 +31,15 @@ class Auth {
|
|
|
30
31
|
onRefreshTokenCallback: ?Function;
|
|
31
32
|
authenticated: boolean;
|
|
32
33
|
mobile: boolean;
|
|
34
|
+
BACKEND_WAZO: string;
|
|
35
|
+
BACKEND_LDAP: string;
|
|
33
36
|
|
|
34
37
|
constructor() {
|
|
35
38
|
this.expiration = DETAULT_EXPIRATION;
|
|
36
39
|
this.authenticated = false;
|
|
37
40
|
this.minSubscriptionType = null;
|
|
41
|
+
this.BACKEND_WAZO = DEFAULT_BACKEND_USER;
|
|
42
|
+
this.BACKEND_LDAP = BACKEND_LDAP_USER;
|
|
38
43
|
}
|
|
39
44
|
|
|
40
45
|
init(clientId: string,
|
|
@@ -67,15 +72,28 @@ class Auth {
|
|
|
67
72
|
setFetchOptions(options);
|
|
68
73
|
}
|
|
69
74
|
|
|
70
|
-
async logIn(username: string, password: string) {
|
|
75
|
+
async logIn(username: string, password: string, backend?: string, tenantId?: string) {
|
|
76
|
+
if (backend && backend !== this.BACKEND_WAZO && !tenantId) {
|
|
77
|
+
throw new NoTenantIdError('No tenant id');
|
|
78
|
+
}
|
|
79
|
+
|
|
71
80
|
this.authenticated = false;
|
|
72
81
|
this.session = null;
|
|
73
82
|
const rawSession = await getApiClient().auth.logIn({
|
|
74
83
|
username,
|
|
75
84
|
password,
|
|
85
|
+
backend,
|
|
86
|
+
tenantId,
|
|
76
87
|
expiration: this.expiration,
|
|
77
88
|
mobile: this.mobile,
|
|
78
89
|
});
|
|
90
|
+
|
|
91
|
+
if (backend) {
|
|
92
|
+
getApiClient().setRefreshBackend(backend);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
getApiClient().setRefreshTenantId(tenantId);
|
|
96
|
+
|
|
79
97
|
return this._onAuthenticated(rawSession);
|
|
80
98
|
}
|
|
81
99
|
|
package/src/simple/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* global window */
|
|
2
|
-
import Auth, { InvalidSubscription, InvalidAuthorization } from './Auth';
|
|
2
|
+
import Auth, { InvalidSubscription, InvalidAuthorization, NoTenantIdError } from './Auth';
|
|
3
3
|
import Phone from './Phone';
|
|
4
4
|
import Websocket from './Websocket';
|
|
5
5
|
import Room from './room/Room';
|
|
@@ -103,6 +103,7 @@ const Wazo = {
|
|
|
103
103
|
InvalidAuthorization,
|
|
104
104
|
CanceledCallError,
|
|
105
105
|
SFUNotAvailableError,
|
|
106
|
+
NoTenantIdError,
|
|
106
107
|
};
|
|
107
108
|
|
|
108
109
|
if (window) {
|