@wazo/sdk 0.38.7 → 0.38.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/wazo-sdk.js +2 -2
- package/esm/__tests__/api-client.test.js +163 -2
- package/esm/__tests__/web-rtc-client.test.js +248 -27
- package/esm/api/auth.js +12 -0
- package/esm/api/calld.js +8 -0
- package/esm/api/confd.js +134 -2
- package/esm/api/ctid-ng.js +1 -0
- package/esm/api-client.js +163 -2
- package/esm/checker/Checker.js +204 -24
- package/esm/checker/checks/aor.js +163 -2
- package/esm/checker/checks/api.js +163 -2
- package/esm/checker/checks/index.js +204 -24
- package/esm/checker/checks/wazo-websocket.js +2 -0
- package/esm/checker/checks/webrtc-transport.js +202 -24
- package/esm/checker/checks/webrtc.js +202 -24
- package/esm/domain/AdHocAPIConference.js +170 -4
- package/esm/domain/Features.js +170 -4
- package/esm/domain/Meeting.js +18 -0
- package/esm/domain/MeetingAuthorization.js +70 -0
- package/esm/domain/Phone/CTIPhone.js +170 -4
- package/esm/domain/Phone/WebRTCPhone.js +2 -3
- package/esm/domain/__tests__/Meeting.test.js +87 -1
- package/esm/domain/__tests__/MeetingAuthorization.test.js +109 -0
- package/esm/index.js +300 -36
- package/esm/service/CallApi.js +170 -4
- package/esm/service/getApiClient.js +176 -5
- package/esm/simple/Auth.js +301 -37
- package/esm/simple/Configuration.js +300 -36
- package/esm/simple/Directory.js +170 -4
- package/esm/simple/Phone.js +300 -36
- package/esm/simple/Softphone.js +5 -0
- package/esm/simple/Websocket.js +3 -0
- package/esm/simple/index.js +300 -36
- package/esm/simple/room/LocalParticipant.js +300 -36
- package/esm/simple/room/Participant.js +300 -36
- package/esm/simple/room/RemoteParticipant.js +300 -36
- package/esm/simple/room/Room.js +300 -36
- package/esm/simple/room/SipRoom.js +300 -36
- package/esm/simple/room/Stream.js +300 -36
- package/esm/simple/room/__tests__/Participant.test.js +14812 -0
- package/esm/simple/room/__tests__/RemoteParticipant.test.js +300 -36
- package/esm/simple/utils.js +300 -36
- package/esm/utils/__tests__/object.test.js +57 -0
- package/esm/utils/__tests__/string.test.js +30 -0
- package/esm/utils/object.js +24 -0
- package/esm/utils/string.js +10 -0
- package/esm/web-rtc-client.js +202 -24
- package/esm/websocket-client.js +3 -1
- package/lib/__tests__/api-client.test.js +163 -2
- package/lib/__tests__/web-rtc-client.test.js +248 -27
- package/lib/api/auth.js +12 -0
- package/lib/api/calld.js +8 -0
- package/lib/api/confd.js +134 -2
- package/lib/api/ctid-ng.js +1 -0
- package/lib/api-client.js +163 -2
- package/lib/checker/Checker.js +204 -24
- package/lib/checker/checks/aor.js +163 -2
- package/lib/checker/checks/api.js +163 -2
- package/lib/checker/checks/index.js +204 -24
- package/lib/checker/checks/wazo-websocket.js +2 -0
- package/lib/checker/checks/webrtc-transport.js +202 -24
- package/lib/checker/checks/webrtc.js +202 -24
- package/lib/domain/AdHocAPIConference.js +170 -4
- package/lib/domain/Features.js +170 -4
- package/lib/domain/Meeting.js +18 -0
- package/lib/domain/MeetingAuthorization.js +79 -0
- package/lib/domain/Phone/CTIPhone.js +170 -4
- package/lib/domain/Phone/WebRTCPhone.js +2 -3
- package/lib/domain/__tests__/Meeting.test.js +87 -1
- package/lib/domain/__tests__/MeetingAuthorization.test.js +111 -0
- package/lib/index.js +300 -36
- package/lib/service/CallApi.js +170 -4
- package/lib/service/getApiClient.js +176 -4
- package/lib/simple/Auth.js +301 -36
- package/lib/simple/Configuration.js +300 -36
- package/lib/simple/Directory.js +170 -4
- package/lib/simple/Phone.js +300 -36
- package/lib/simple/Softphone.js +5 -0
- package/lib/simple/Websocket.js +3 -0
- package/lib/simple/index.js +300 -36
- package/lib/simple/room/LocalParticipant.js +300 -36
- package/lib/simple/room/Participant.js +300 -36
- package/lib/simple/room/RemoteParticipant.js +300 -36
- package/lib/simple/room/Room.js +300 -36
- package/lib/simple/room/SipRoom.js +300 -36
- package/lib/simple/room/Stream.js +300 -36
- package/lib/simple/room/__tests__/Participant.test.js +14822 -0
- package/lib/simple/room/__tests__/RemoteParticipant.test.js +300 -36
- package/lib/simple/utils.js +300 -36
- package/lib/utils/__tests__/object.test.js +59 -0
- package/lib/utils/__tests__/string.test.js +32 -0
- package/lib/utils/object.js +28 -0
- package/lib/utils/string.js +14 -0
- package/lib/web-rtc-client.js +202 -24
- package/lib/websocket-client.js +3 -0
- package/package.json +1 -1
- package/src/__tests__/web-rtc-client.test.js +46 -3
- package/src/api/auth.js +12 -0
- package/src/api/calld.js +8 -0
- package/src/api/confd.js +43 -2
- package/src/api-client.js +8 -0
- package/src/domain/Meeting.js +20 -0
- package/src/domain/MeetingAuthorization.js +67 -0
- package/src/domain/Phone/WebRTCPhone.js +1 -3
- package/src/domain/__tests__/Meeting.test.js +70 -1
- package/src/domain/__tests__/MeetingAuthorization.test.js +58 -0
- package/src/service/getApiClient.js +13 -2
- package/src/simple/Auth.js +35 -4
- package/src/simple/Softphone.js +5 -0
- package/src/simple/index.js +2 -1
- package/src/simple/room/Participant.js +40 -0
- package/src/simple/room/Room.js +2 -2
- package/src/simple/room/SipRoom.js +1 -1
- package/src/simple/room/__tests__/Participant.test.js +81 -0
- package/src/types/WebSocketMessage.js +7 -1
- package/src/utils/__tests__/object.test.js +35 -0
- package/src/utils/__tests__/string.test.js +23 -0
- package/src/utils/object.js +15 -0
- package/src/utils/string.js +8 -0
- package/src/web-rtc-client.js +39 -22
- package/src/websocket-client.js +2 -0
package/esm/service/CallApi.js
CHANGED
|
@@ -2755,6 +2755,7 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2755
2755
|
|
|
2756
2756
|
|
|
2757
2757
|
|
|
2758
|
+
|
|
2758
2759
|
) {
|
|
2759
2760
|
const body = {
|
|
2760
2761
|
backend: params.backend || DEFAULT_BACKEND_USER,
|
|
@@ -2775,9 +2776,14 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2775
2776
|
}
|
|
2776
2777
|
|
|
2777
2778
|
if (params.tenantId) {
|
|
2779
|
+
console.warn('Use of `tenantId` is deprecated when calling logIn() method, use `domainName` instead.');
|
|
2778
2780
|
body.tenant_id = params.tenantId;
|
|
2779
2781
|
}
|
|
2780
2782
|
|
|
2783
|
+
if (params.domainName) {
|
|
2784
|
+
body.domain_name = params.domainName;
|
|
2785
|
+
}
|
|
2786
|
+
|
|
2781
2787
|
return client.post(`${baseUrl}/token`, body, headers).then(response => Session.parse(response));
|
|
2782
2788
|
},
|
|
2783
2789
|
|
|
@@ -2790,6 +2796,7 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2790
2796
|
expiration ,
|
|
2791
2797
|
isMobile = false,
|
|
2792
2798
|
tenantId ,
|
|
2799
|
+
domainName ,
|
|
2793
2800
|
) => {
|
|
2794
2801
|
const body = {
|
|
2795
2802
|
backend: backend || DEFAULT_BACKEND_USER,
|
|
@@ -2799,9 +2806,14 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2799
2806
|
};
|
|
2800
2807
|
|
|
2801
2808
|
if (tenantId) {
|
|
2809
|
+
console.warn('Use of `tenantId` is deprecated when calling refreshToken() method, use `domainName` instead.');
|
|
2802
2810
|
body.tenant_id = tenantId;
|
|
2803
2811
|
}
|
|
2804
2812
|
|
|
2813
|
+
if (domainName) {
|
|
2814
|
+
body.domain_name = domainName;
|
|
2815
|
+
}
|
|
2816
|
+
|
|
2805
2817
|
const headers = {
|
|
2806
2818
|
'Content-Type': 'application/json',
|
|
2807
2819
|
...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),
|
|
@@ -3171,6 +3183,70 @@ class ExternalApp {
|
|
|
3171
3183
|
|
|
3172
3184
|
//
|
|
3173
3185
|
|
|
3186
|
+
class MeetingAuthorization {
|
|
3187
|
+
|
|
3188
|
+
|
|
3189
|
+
|
|
3190
|
+
|
|
3191
|
+
|
|
3192
|
+
|
|
3193
|
+
constructor({
|
|
3194
|
+
meetingUuid,
|
|
3195
|
+
uuid,
|
|
3196
|
+
userUuid,
|
|
3197
|
+
userName,
|
|
3198
|
+
} = {}) {
|
|
3199
|
+
this.meetingUuid = meetingUuid;
|
|
3200
|
+
this.uuid = uuid;
|
|
3201
|
+
this.userUuid = userUuid;
|
|
3202
|
+
this.userName = userName;
|
|
3203
|
+
}
|
|
3204
|
+
|
|
3205
|
+
setStatus(status ) {
|
|
3206
|
+
this.status = status;
|
|
3207
|
+
}
|
|
3208
|
+
|
|
3209
|
+
getStatus() {
|
|
3210
|
+
return this.status;
|
|
3211
|
+
}
|
|
3212
|
+
|
|
3213
|
+
static parse(plain ) {
|
|
3214
|
+
const {
|
|
3215
|
+
meeting_uuid: meetingUuid,
|
|
3216
|
+
uuid,
|
|
3217
|
+
guest_uuid: userUuid,
|
|
3218
|
+
guest_name: userName,
|
|
3219
|
+
} = plain;
|
|
3220
|
+
|
|
3221
|
+
return new MeetingAuthorization({
|
|
3222
|
+
meetingUuid,
|
|
3223
|
+
uuid,
|
|
3224
|
+
userUuid,
|
|
3225
|
+
userName,
|
|
3226
|
+
});
|
|
3227
|
+
}
|
|
3228
|
+
|
|
3229
|
+
static parseMany(items ) {
|
|
3230
|
+
if (!items) {
|
|
3231
|
+
return [];
|
|
3232
|
+
}
|
|
3233
|
+
return items.map(MeetingAuthorization.parse);
|
|
3234
|
+
}
|
|
3235
|
+
}
|
|
3236
|
+
|
|
3237
|
+
//
|
|
3238
|
+
|
|
3239
|
+
|
|
3240
|
+
|
|
3241
|
+
|
|
3242
|
+
|
|
3243
|
+
|
|
3244
|
+
|
|
3245
|
+
|
|
3246
|
+
|
|
3247
|
+
|
|
3248
|
+
|
|
3249
|
+
|
|
3174
3250
|
|
|
3175
3251
|
|
|
3176
3252
|
|
|
@@ -3181,6 +3257,7 @@ class ExternalApp {
|
|
|
3181
3257
|
|
|
3182
3258
|
|
|
3183
3259
|
|
|
3260
|
+
|
|
3184
3261
|
|
|
3185
3262
|
|
|
3186
3263
|
class Meeting {
|
|
@@ -3195,6 +3272,8 @@ class Meeting {
|
|
|
3195
3272
|
|
|
3196
3273
|
|
|
3197
3274
|
|
|
3275
|
+
|
|
3276
|
+
|
|
3198
3277
|
|
|
3199
3278
|
static parse(plain ) {
|
|
3200
3279
|
return new Meeting({
|
|
@@ -3207,6 +3286,7 @@ class Meeting {
|
|
|
3207
3286
|
extension: plain.exten,
|
|
3208
3287
|
persistent: plain.persistent,
|
|
3209
3288
|
creationTime: moment(plain.creation_time).toDate(),
|
|
3289
|
+
requireAuthorization: plain.require_authorization,
|
|
3210
3290
|
});
|
|
3211
3291
|
}
|
|
3212
3292
|
|
|
@@ -3231,6 +3311,7 @@ class Meeting {
|
|
|
3231
3311
|
extension,
|
|
3232
3312
|
persistent,
|
|
3233
3313
|
creationTime,
|
|
3314
|
+
requireAuthorization,
|
|
3234
3315
|
} = {}) {
|
|
3235
3316
|
this.guestSipAuthorization = guestSipAuthorization;
|
|
3236
3317
|
this.uri = uri;
|
|
@@ -3241,6 +3322,7 @@ class Meeting {
|
|
|
3241
3322
|
this.extension = extension;
|
|
3242
3323
|
this.persistent = persistent;
|
|
3243
3324
|
this.creationTime = creationTime;
|
|
3325
|
+
this.requireAuthorization = requireAuthorization;
|
|
3244
3326
|
|
|
3245
3327
|
// Useful to compare instead of instanceof with minified code
|
|
3246
3328
|
this.type = 'Meeting';
|
|
@@ -3251,8 +3333,32 @@ class Meeting {
|
|
|
3251
3333
|
const [username, secret] = atob(this.guestSipAuthorization).split(':');
|
|
3252
3334
|
return { username, secret };
|
|
3253
3335
|
}
|
|
3336
|
+
|
|
3254
3337
|
}
|
|
3255
3338
|
|
|
3339
|
+
//
|
|
3340
|
+
|
|
3341
|
+
const camelToUnderscore = (key ) => {
|
|
3342
|
+
if (typeof key !== 'string') {
|
|
3343
|
+
throw new Error('Input is not a string');
|
|
3344
|
+
}
|
|
3345
|
+
return key.charAt(0).toLowerCase() + key.substring(1).replace(/([A-Z])/g, '_$1').toLowerCase();
|
|
3346
|
+
};
|
|
3347
|
+
|
|
3348
|
+
//
|
|
3349
|
+
|
|
3350
|
+
const convertKeysFromCamelToUnderscore = (args ) => {
|
|
3351
|
+
if (!args || typeof args !== 'object' || Array.isArray(args)) {
|
|
3352
|
+
throw new Error('Input is not an object');
|
|
3353
|
+
}
|
|
3354
|
+
|
|
3355
|
+
return Object.keys(args).reduce((acc, key) => {
|
|
3356
|
+
acc[camelToUnderscore(key)] = typeof args[key] === 'object' && !Array.isArray(args[key])
|
|
3357
|
+
? convertKeysFromCamelToUnderscore(args[key]) : args[key];
|
|
3358
|
+
return acc;
|
|
3359
|
+
}, {});
|
|
3360
|
+
};
|
|
3361
|
+
|
|
3256
3362
|
/* */
|
|
3257
3363
|
|
|
3258
3364
|
var confdMethods = (client , baseUrl ) => ({
|
|
@@ -3321,8 +3427,18 @@ var confdMethods = (client , baseUrl ) => ({
|
|
|
3321
3427
|
getMyMeetings: () =>
|
|
3322
3428
|
client.get(`${baseUrl}/users/me/meetings`).then(response => Meeting.parseMany(response.items)),
|
|
3323
3429
|
|
|
3324
|
-
createMyMeeting: (
|
|
3325
|
-
client
|
|
3430
|
+
createMyMeeting: (args ) =>
|
|
3431
|
+
client
|
|
3432
|
+
.post(`${baseUrl}/users/me/meetings`, convertKeysFromCamelToUnderscore(args))
|
|
3433
|
+
.then(Meeting.parse),
|
|
3434
|
+
|
|
3435
|
+
updateMyMeeting: (meetingUuid , data ) =>
|
|
3436
|
+
client.put(
|
|
3437
|
+
`${baseUrl}/users/me/meetings/${meetingUuid}`,
|
|
3438
|
+
convertKeysFromCamelToUnderscore(data),
|
|
3439
|
+
null,
|
|
3440
|
+
ApiRequester.successResponseParser,
|
|
3441
|
+
),
|
|
3326
3442
|
|
|
3327
3443
|
deleteMyMeeting: (meetingUuid ) =>
|
|
3328
3444
|
client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
|
|
@@ -3330,8 +3446,36 @@ var confdMethods = (client , baseUrl ) => ({
|
|
|
3330
3446
|
getMeeting: (meetingUuid ) =>
|
|
3331
3447
|
client.get(`${baseUrl}/meetings/${meetingUuid}`, null).then(Meeting.parse),
|
|
3332
3448
|
|
|
3449
|
+
meetingAuthorizations: (meetingUuid ) =>
|
|
3450
|
+
client.get(`${baseUrl}/users/me/meetings/${meetingUuid}/authorizations`, null).then(MeetingAuthorization.parseMany),
|
|
3451
|
+
|
|
3452
|
+
meetingAuthorizationReject: (meetingUuid , authorizationUuid ) =>
|
|
3453
|
+
client.put(
|
|
3454
|
+
`${baseUrl}/users/me/meetings/${meetingUuid}/authorizations/${authorizationUuid}/reject`,
|
|
3455
|
+
{},
|
|
3456
|
+
null,
|
|
3457
|
+
ApiRequester.successResponseParser,
|
|
3458
|
+
),
|
|
3459
|
+
|
|
3460
|
+
meetingAuthorizationAccept: (meetingUuid , authorizationUuid ) =>
|
|
3461
|
+
client.put(
|
|
3462
|
+
`${baseUrl}/users/me/meetings/${meetingUuid}/authorizations/${authorizationUuid}/accept`,
|
|
3463
|
+
{},
|
|
3464
|
+
null,
|
|
3465
|
+
ApiRequester.successResponseParser,
|
|
3466
|
+
),
|
|
3467
|
+
|
|
3333
3468
|
guestGetMeeting: (meetingUuid ) =>
|
|
3334
3469
|
client.get(`${baseUrl}/guests/me/meetings/${meetingUuid}`, null).then(Meeting.parse),
|
|
3470
|
+
|
|
3471
|
+
guestAuthorizationRequest: (userUuid , meetingUuid , username ) =>
|
|
3472
|
+
client
|
|
3473
|
+
.post(`${baseUrl}/guests/${userUuid}/meetings/${meetingUuid}/authorizations`, { guest_name: username })
|
|
3474
|
+
.then(MeetingAuthorization.parse),
|
|
3475
|
+
|
|
3476
|
+
guestAuthorizationCheck: (userUuid , meetingUuid , authorizationUuid ) =>
|
|
3477
|
+
client.get(`${baseUrl}/guests/${userUuid}/meetings/${meetingUuid}/authorizations/${authorizationUuid}`, null),
|
|
3478
|
+
|
|
3335
3479
|
});
|
|
3336
3480
|
|
|
3337
3481
|
//
|
|
@@ -4207,6 +4351,14 @@ var calldMethods = (client , baseUrl ) => ({
|
|
|
4207
4351
|
getMeetingParticipantsAsUser: async (meetingUuid ) =>
|
|
4208
4352
|
client.get(`${baseUrl}/users/me/meetings/${meetingUuid}/participants`),
|
|
4209
4353
|
|
|
4354
|
+
banMeetingParticipant: (meetingUuid , participantUuid ) =>
|
|
4355
|
+
client.delete(
|
|
4356
|
+
`${baseUrl}/users/me/meetings/${meetingUuid}/participants/${participantUuid}`,
|
|
4357
|
+
null,
|
|
4358
|
+
null,
|
|
4359
|
+
ApiRequester.successResponseParser,
|
|
4360
|
+
),
|
|
4361
|
+
|
|
4210
4362
|
listTrunks: () => client.get(`${baseUrl}/trunks`),
|
|
4211
4363
|
|
|
4212
4364
|
mute: (callId ) =>
|
|
@@ -4584,6 +4736,7 @@ class ApiClient {
|
|
|
4584
4736
|
|
|
4585
4737
|
|
|
4586
4738
|
|
|
4739
|
+
|
|
4587
4740
|
|
|
4588
4741
|
|
|
4589
4742
|
|
|
@@ -4625,6 +4778,7 @@ class ApiClient {
|
|
|
4625
4778
|
refreshToken: this.refreshToken,
|
|
4626
4779
|
refreshBackend: this.refreshBackend,
|
|
4627
4780
|
refreshTenantId: this.refreshTenantId,
|
|
4781
|
+
refreshDomainName: this.refreshDomainName,
|
|
4628
4782
|
refreshExpiration: this.refreshExpiration,
|
|
4629
4783
|
isMobile: this.isMobile,
|
|
4630
4784
|
});
|
|
@@ -4640,6 +4794,7 @@ class ApiClient {
|
|
|
4640
4794
|
this.refreshExpiration,
|
|
4641
4795
|
this.isMobile,
|
|
4642
4796
|
this.refreshTenantId,
|
|
4797
|
+
this.refreshDomainName,
|
|
4643
4798
|
);
|
|
4644
4799
|
|
|
4645
4800
|
logger.info('token refreshed', { token: session.token });
|
|
@@ -4693,9 +4848,14 @@ class ApiClient {
|
|
|
4693
4848
|
}
|
|
4694
4849
|
|
|
4695
4850
|
setRefreshTenantId(tenantId ) {
|
|
4851
|
+
console.warn('Use of `setRefreshTenantId` is deprecated, use `setRefreshDomainName` instead');
|
|
4696
4852
|
this.refreshTenantId = tenantId;
|
|
4697
4853
|
}
|
|
4698
4854
|
|
|
4855
|
+
setRefreshDomainName(domainName ) {
|
|
4856
|
+
this.refreshDomainName = domainName;
|
|
4857
|
+
}
|
|
4858
|
+
|
|
4699
4859
|
setIsMobile(isMobile ) {
|
|
4700
4860
|
this.isMobile = isMobile;
|
|
4701
4861
|
}
|
|
@@ -4720,6 +4880,7 @@ global.wazoClientId = global.wazoClientId || {};
|
|
|
4720
4880
|
global.wazoClientToken = global.wazoClientToken || {};
|
|
4721
4881
|
global.wazoRefreshToken = global.wazoRefreshToken || {};
|
|
4722
4882
|
global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
|
|
4883
|
+
global.wazoRefreshDomainName = global.wazoRefreshDomainName || {};
|
|
4723
4884
|
global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
|
|
4724
4885
|
global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
|
|
4725
4886
|
global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
|
|
@@ -4729,6 +4890,7 @@ global.wazoFetchOptions = global.wazoFetchOptions || {};
|
|
|
4729
4890
|
|
|
4730
4891
|
const fillClient = (apiClient ) => {
|
|
4731
4892
|
const { server, token, clientId } = apiClient.client;
|
|
4893
|
+
const tenantId = global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId;
|
|
4732
4894
|
|
|
4733
4895
|
// try with null server when dealing with non-related server info
|
|
4734
4896
|
apiClient.setToken(global.wazoClientToken[server] || global.wazoClientToken[null] || token);
|
|
@@ -4737,8 +4899,12 @@ const fillClient = (apiClient ) => {
|
|
|
4737
4899
|
|
|
4738
4900
|
apiClient.setRefreshToken(global.wazoRefreshToken[server] || global.wazoRefreshToken[null] || apiClient.refreshToken);
|
|
4739
4901
|
|
|
4740
|
-
|
|
4741
|
-
|
|
4902
|
+
if (tenantId) {
|
|
4903
|
+
apiClient.setRefreshTenantId(tenantId);
|
|
4904
|
+
}
|
|
4905
|
+
|
|
4906
|
+
apiClient.setRefreshDomainName(
|
|
4907
|
+
global.wazoRefreshDomainName[server] || global.wazoRefreshDomainName[null] || apiClient.refreshDomainName,
|
|
4742
4908
|
);
|
|
4743
4909
|
|
|
4744
4910
|
apiClient.setFetchOptions(global.wazoFetchOptions[server] || global.wazoFetchOptions[null] || apiClient.fetchOptions);
|
|
@@ -2209,6 +2209,7 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2209
2209
|
|
|
2210
2210
|
|
|
2211
2211
|
|
|
2212
|
+
|
|
2212
2213
|
) {
|
|
2213
2214
|
const body = {
|
|
2214
2215
|
backend: params.backend || DEFAULT_BACKEND_USER,
|
|
@@ -2229,9 +2230,14 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2229
2230
|
}
|
|
2230
2231
|
|
|
2231
2232
|
if (params.tenantId) {
|
|
2233
|
+
console.warn('Use of `tenantId` is deprecated when calling logIn() method, use `domainName` instead.');
|
|
2232
2234
|
body.tenant_id = params.tenantId;
|
|
2233
2235
|
}
|
|
2234
2236
|
|
|
2237
|
+
if (params.domainName) {
|
|
2238
|
+
body.domain_name = params.domainName;
|
|
2239
|
+
}
|
|
2240
|
+
|
|
2235
2241
|
return client.post(`${baseUrl}/token`, body, headers).then(response => Session.parse(response));
|
|
2236
2242
|
},
|
|
2237
2243
|
|
|
@@ -2244,6 +2250,7 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2244
2250
|
expiration ,
|
|
2245
2251
|
isMobile = false,
|
|
2246
2252
|
tenantId ,
|
|
2253
|
+
domainName ,
|
|
2247
2254
|
) => {
|
|
2248
2255
|
const body = {
|
|
2249
2256
|
backend: backend || DEFAULT_BACKEND_USER,
|
|
@@ -2253,9 +2260,14 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2253
2260
|
};
|
|
2254
2261
|
|
|
2255
2262
|
if (tenantId) {
|
|
2263
|
+
console.warn('Use of `tenantId` is deprecated when calling refreshToken() method, use `domainName` instead.');
|
|
2256
2264
|
body.tenant_id = tenantId;
|
|
2257
2265
|
}
|
|
2258
2266
|
|
|
2267
|
+
if (domainName) {
|
|
2268
|
+
body.domain_name = domainName;
|
|
2269
|
+
}
|
|
2270
|
+
|
|
2259
2271
|
const headers = {
|
|
2260
2272
|
'Content-Type': 'application/json',
|
|
2261
2273
|
...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),
|
|
@@ -2625,6 +2637,70 @@ class ExternalApp {
|
|
|
2625
2637
|
|
|
2626
2638
|
//
|
|
2627
2639
|
|
|
2640
|
+
class MeetingAuthorization {
|
|
2641
|
+
|
|
2642
|
+
|
|
2643
|
+
|
|
2644
|
+
|
|
2645
|
+
|
|
2646
|
+
|
|
2647
|
+
constructor({
|
|
2648
|
+
meetingUuid,
|
|
2649
|
+
uuid,
|
|
2650
|
+
userUuid,
|
|
2651
|
+
userName,
|
|
2652
|
+
} = {}) {
|
|
2653
|
+
this.meetingUuid = meetingUuid;
|
|
2654
|
+
this.uuid = uuid;
|
|
2655
|
+
this.userUuid = userUuid;
|
|
2656
|
+
this.userName = userName;
|
|
2657
|
+
}
|
|
2658
|
+
|
|
2659
|
+
setStatus(status ) {
|
|
2660
|
+
this.status = status;
|
|
2661
|
+
}
|
|
2662
|
+
|
|
2663
|
+
getStatus() {
|
|
2664
|
+
return this.status;
|
|
2665
|
+
}
|
|
2666
|
+
|
|
2667
|
+
static parse(plain ) {
|
|
2668
|
+
const {
|
|
2669
|
+
meeting_uuid: meetingUuid,
|
|
2670
|
+
uuid,
|
|
2671
|
+
guest_uuid: userUuid,
|
|
2672
|
+
guest_name: userName,
|
|
2673
|
+
} = plain;
|
|
2674
|
+
|
|
2675
|
+
return new MeetingAuthorization({
|
|
2676
|
+
meetingUuid,
|
|
2677
|
+
uuid,
|
|
2678
|
+
userUuid,
|
|
2679
|
+
userName,
|
|
2680
|
+
});
|
|
2681
|
+
}
|
|
2682
|
+
|
|
2683
|
+
static parseMany(items ) {
|
|
2684
|
+
if (!items) {
|
|
2685
|
+
return [];
|
|
2686
|
+
}
|
|
2687
|
+
return items.map(MeetingAuthorization.parse);
|
|
2688
|
+
}
|
|
2689
|
+
}
|
|
2690
|
+
|
|
2691
|
+
//
|
|
2692
|
+
|
|
2693
|
+
|
|
2694
|
+
|
|
2695
|
+
|
|
2696
|
+
|
|
2697
|
+
|
|
2698
|
+
|
|
2699
|
+
|
|
2700
|
+
|
|
2701
|
+
|
|
2702
|
+
|
|
2703
|
+
|
|
2628
2704
|
|
|
2629
2705
|
|
|
2630
2706
|
|
|
@@ -2635,6 +2711,7 @@ class ExternalApp {
|
|
|
2635
2711
|
|
|
2636
2712
|
|
|
2637
2713
|
|
|
2714
|
+
|
|
2638
2715
|
|
|
2639
2716
|
|
|
2640
2717
|
class Meeting {
|
|
@@ -2649,6 +2726,8 @@ class Meeting {
|
|
|
2649
2726
|
|
|
2650
2727
|
|
|
2651
2728
|
|
|
2729
|
+
|
|
2730
|
+
|
|
2652
2731
|
|
|
2653
2732
|
static parse(plain ) {
|
|
2654
2733
|
return new Meeting({
|
|
@@ -2661,6 +2740,7 @@ class Meeting {
|
|
|
2661
2740
|
extension: plain.exten,
|
|
2662
2741
|
persistent: plain.persistent,
|
|
2663
2742
|
creationTime: moment(plain.creation_time).toDate(),
|
|
2743
|
+
requireAuthorization: plain.require_authorization,
|
|
2664
2744
|
});
|
|
2665
2745
|
}
|
|
2666
2746
|
|
|
@@ -2685,6 +2765,7 @@ class Meeting {
|
|
|
2685
2765
|
extension,
|
|
2686
2766
|
persistent,
|
|
2687
2767
|
creationTime,
|
|
2768
|
+
requireAuthorization,
|
|
2688
2769
|
} = {}) {
|
|
2689
2770
|
this.guestSipAuthorization = guestSipAuthorization;
|
|
2690
2771
|
this.uri = uri;
|
|
@@ -2695,6 +2776,7 @@ class Meeting {
|
|
|
2695
2776
|
this.extension = extension;
|
|
2696
2777
|
this.persistent = persistent;
|
|
2697
2778
|
this.creationTime = creationTime;
|
|
2779
|
+
this.requireAuthorization = requireAuthorization;
|
|
2698
2780
|
|
|
2699
2781
|
// Useful to compare instead of instanceof with minified code
|
|
2700
2782
|
this.type = 'Meeting';
|
|
@@ -2705,8 +2787,32 @@ class Meeting {
|
|
|
2705
2787
|
const [username, secret] = atob(this.guestSipAuthorization).split(':');
|
|
2706
2788
|
return { username, secret };
|
|
2707
2789
|
}
|
|
2790
|
+
|
|
2708
2791
|
}
|
|
2709
2792
|
|
|
2793
|
+
//
|
|
2794
|
+
|
|
2795
|
+
const camelToUnderscore = (key ) => {
|
|
2796
|
+
if (typeof key !== 'string') {
|
|
2797
|
+
throw new Error('Input is not a string');
|
|
2798
|
+
}
|
|
2799
|
+
return key.charAt(0).toLowerCase() + key.substring(1).replace(/([A-Z])/g, '_$1').toLowerCase();
|
|
2800
|
+
};
|
|
2801
|
+
|
|
2802
|
+
//
|
|
2803
|
+
|
|
2804
|
+
const convertKeysFromCamelToUnderscore = (args ) => {
|
|
2805
|
+
if (!args || typeof args !== 'object' || Array.isArray(args)) {
|
|
2806
|
+
throw new Error('Input is not an object');
|
|
2807
|
+
}
|
|
2808
|
+
|
|
2809
|
+
return Object.keys(args).reduce((acc, key) => {
|
|
2810
|
+
acc[camelToUnderscore(key)] = typeof args[key] === 'object' && !Array.isArray(args[key])
|
|
2811
|
+
? convertKeysFromCamelToUnderscore(args[key]) : args[key];
|
|
2812
|
+
return acc;
|
|
2813
|
+
}, {});
|
|
2814
|
+
};
|
|
2815
|
+
|
|
2710
2816
|
/* */
|
|
2711
2817
|
|
|
2712
2818
|
var confdMethods = (client , baseUrl ) => ({
|
|
@@ -2775,8 +2881,18 @@ var confdMethods = (client , baseUrl ) => ({
|
|
|
2775
2881
|
getMyMeetings: () =>
|
|
2776
2882
|
client.get(`${baseUrl}/users/me/meetings`).then(response => Meeting.parseMany(response.items)),
|
|
2777
2883
|
|
|
2778
|
-
createMyMeeting: (
|
|
2779
|
-
client
|
|
2884
|
+
createMyMeeting: (args ) =>
|
|
2885
|
+
client
|
|
2886
|
+
.post(`${baseUrl}/users/me/meetings`, convertKeysFromCamelToUnderscore(args))
|
|
2887
|
+
.then(Meeting.parse),
|
|
2888
|
+
|
|
2889
|
+
updateMyMeeting: (meetingUuid , data ) =>
|
|
2890
|
+
client.put(
|
|
2891
|
+
`${baseUrl}/users/me/meetings/${meetingUuid}`,
|
|
2892
|
+
convertKeysFromCamelToUnderscore(data),
|
|
2893
|
+
null,
|
|
2894
|
+
ApiRequester.successResponseParser,
|
|
2895
|
+
),
|
|
2780
2896
|
|
|
2781
2897
|
deleteMyMeeting: (meetingUuid ) =>
|
|
2782
2898
|
client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
|
|
@@ -2784,8 +2900,36 @@ var confdMethods = (client , baseUrl ) => ({
|
|
|
2784
2900
|
getMeeting: (meetingUuid ) =>
|
|
2785
2901
|
client.get(`${baseUrl}/meetings/${meetingUuid}`, null).then(Meeting.parse),
|
|
2786
2902
|
|
|
2903
|
+
meetingAuthorizations: (meetingUuid ) =>
|
|
2904
|
+
client.get(`${baseUrl}/users/me/meetings/${meetingUuid}/authorizations`, null).then(MeetingAuthorization.parseMany),
|
|
2905
|
+
|
|
2906
|
+
meetingAuthorizationReject: (meetingUuid , authorizationUuid ) =>
|
|
2907
|
+
client.put(
|
|
2908
|
+
`${baseUrl}/users/me/meetings/${meetingUuid}/authorizations/${authorizationUuid}/reject`,
|
|
2909
|
+
{},
|
|
2910
|
+
null,
|
|
2911
|
+
ApiRequester.successResponseParser,
|
|
2912
|
+
),
|
|
2913
|
+
|
|
2914
|
+
meetingAuthorizationAccept: (meetingUuid , authorizationUuid ) =>
|
|
2915
|
+
client.put(
|
|
2916
|
+
`${baseUrl}/users/me/meetings/${meetingUuid}/authorizations/${authorizationUuid}/accept`,
|
|
2917
|
+
{},
|
|
2918
|
+
null,
|
|
2919
|
+
ApiRequester.successResponseParser,
|
|
2920
|
+
),
|
|
2921
|
+
|
|
2787
2922
|
guestGetMeeting: (meetingUuid ) =>
|
|
2788
2923
|
client.get(`${baseUrl}/guests/me/meetings/${meetingUuid}`, null).then(Meeting.parse),
|
|
2924
|
+
|
|
2925
|
+
guestAuthorizationRequest: (userUuid , meetingUuid , username ) =>
|
|
2926
|
+
client
|
|
2927
|
+
.post(`${baseUrl}/guests/${userUuid}/meetings/${meetingUuid}/authorizations`, { guest_name: username })
|
|
2928
|
+
.then(MeetingAuthorization.parse),
|
|
2929
|
+
|
|
2930
|
+
guestAuthorizationCheck: (userUuid , meetingUuid , authorizationUuid ) =>
|
|
2931
|
+
client.get(`${baseUrl}/guests/${userUuid}/meetings/${meetingUuid}/authorizations/${authorizationUuid}`, null),
|
|
2932
|
+
|
|
2789
2933
|
});
|
|
2790
2934
|
|
|
2791
2935
|
//
|
|
@@ -4207,6 +4351,14 @@ var calldMethods = (client , baseUrl ) => ({
|
|
|
4207
4351
|
getMeetingParticipantsAsUser: async (meetingUuid ) =>
|
|
4208
4352
|
client.get(`${baseUrl}/users/me/meetings/${meetingUuid}/participants`),
|
|
4209
4353
|
|
|
4354
|
+
banMeetingParticipant: (meetingUuid , participantUuid ) =>
|
|
4355
|
+
client.delete(
|
|
4356
|
+
`${baseUrl}/users/me/meetings/${meetingUuid}/participants/${participantUuid}`,
|
|
4357
|
+
null,
|
|
4358
|
+
null,
|
|
4359
|
+
ApiRequester.successResponseParser,
|
|
4360
|
+
),
|
|
4361
|
+
|
|
4210
4362
|
listTrunks: () => client.get(`${baseUrl}/trunks`),
|
|
4211
4363
|
|
|
4212
4364
|
mute: (callId ) =>
|
|
@@ -4584,6 +4736,7 @@ class ApiClient {
|
|
|
4584
4736
|
|
|
4585
4737
|
|
|
4586
4738
|
|
|
4739
|
+
|
|
4587
4740
|
|
|
4588
4741
|
|
|
4589
4742
|
|
|
@@ -4625,6 +4778,7 @@ class ApiClient {
|
|
|
4625
4778
|
refreshToken: this.refreshToken,
|
|
4626
4779
|
refreshBackend: this.refreshBackend,
|
|
4627
4780
|
refreshTenantId: this.refreshTenantId,
|
|
4781
|
+
refreshDomainName: this.refreshDomainName,
|
|
4628
4782
|
refreshExpiration: this.refreshExpiration,
|
|
4629
4783
|
isMobile: this.isMobile,
|
|
4630
4784
|
});
|
|
@@ -4640,6 +4794,7 @@ class ApiClient {
|
|
|
4640
4794
|
this.refreshExpiration,
|
|
4641
4795
|
this.isMobile,
|
|
4642
4796
|
this.refreshTenantId,
|
|
4797
|
+
this.refreshDomainName,
|
|
4643
4798
|
);
|
|
4644
4799
|
|
|
4645
4800
|
logger.info('token refreshed', { token: session.token });
|
|
@@ -4693,9 +4848,14 @@ class ApiClient {
|
|
|
4693
4848
|
}
|
|
4694
4849
|
|
|
4695
4850
|
setRefreshTenantId(tenantId ) {
|
|
4851
|
+
console.warn('Use of `setRefreshTenantId` is deprecated, use `setRefreshDomainName` instead');
|
|
4696
4852
|
this.refreshTenantId = tenantId;
|
|
4697
4853
|
}
|
|
4698
4854
|
|
|
4855
|
+
setRefreshDomainName(domainName ) {
|
|
4856
|
+
this.refreshDomainName = domainName;
|
|
4857
|
+
}
|
|
4858
|
+
|
|
4699
4859
|
setIsMobile(isMobile ) {
|
|
4700
4860
|
this.isMobile = isMobile;
|
|
4701
4861
|
}
|
|
@@ -4720,6 +4880,7 @@ global.wazoClientId = global.wazoClientId || {};
|
|
|
4720
4880
|
global.wazoClientToken = global.wazoClientToken || {};
|
|
4721
4881
|
global.wazoRefreshToken = global.wazoRefreshToken || {};
|
|
4722
4882
|
global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
|
|
4883
|
+
global.wazoRefreshDomainName = global.wazoRefreshDomainName || {};
|
|
4723
4884
|
global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
|
|
4724
4885
|
global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
|
|
4725
4886
|
global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
|
|
@@ -4744,9 +4905,14 @@ const setRefreshToken = (newRefreshToken , forServer = null) =>
|
|
|
4744
4905
|
};
|
|
4745
4906
|
|
|
4746
4907
|
const setRefreshTenantId = (refreshTenantId , forServer = null) => {
|
|
4908
|
+
console.warn('Use of `setRefreshTenantId` is deprecated, please use `setRefreshDomainName` instead');
|
|
4747
4909
|
global.wazoRefreshTenantId[forServer] = refreshTenantId;
|
|
4748
4910
|
};
|
|
4749
4911
|
|
|
4912
|
+
const setRefreshDomainName = (refreshDomainName , forServer = null) => {
|
|
4913
|
+
global.wazoRefreshDomainName[forServer] = refreshDomainName;
|
|
4914
|
+
};
|
|
4915
|
+
|
|
4750
4916
|
const setOnRefreshToken = (onRefreshToken , forServer = null) => {
|
|
4751
4917
|
global.wazoOnRefreshToken[forServer] = onRefreshToken;
|
|
4752
4918
|
};
|
|
@@ -4773,6 +4939,7 @@ const setFetchOptions = (fetchOptions , forServer = null) => {
|
|
|
4773
4939
|
|
|
4774
4940
|
const fillClient = (apiClient ) => {
|
|
4775
4941
|
const { server, token, clientId } = apiClient.client;
|
|
4942
|
+
const tenantId = global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId;
|
|
4776
4943
|
|
|
4777
4944
|
// try with null server when dealing with non-related server info
|
|
4778
4945
|
apiClient.setToken(global.wazoClientToken[server] || global.wazoClientToken[null] || token);
|
|
@@ -4781,8 +4948,12 @@ const fillClient = (apiClient ) => {
|
|
|
4781
4948
|
|
|
4782
4949
|
apiClient.setRefreshToken(global.wazoRefreshToken[server] || global.wazoRefreshToken[null] || apiClient.refreshToken);
|
|
4783
4950
|
|
|
4784
|
-
|
|
4785
|
-
|
|
4951
|
+
if (tenantId) {
|
|
4952
|
+
apiClient.setRefreshTenantId(tenantId);
|
|
4953
|
+
}
|
|
4954
|
+
|
|
4955
|
+
apiClient.setRefreshDomainName(
|
|
4956
|
+
global.wazoRefreshDomainName[server] || global.wazoRefreshDomainName[null] || apiClient.refreshDomainName,
|
|
4786
4957
|
);
|
|
4787
4958
|
|
|
4788
4959
|
apiClient.setFetchOptions(global.wazoFetchOptions[server] || global.wazoFetchOptions[null] || apiClient.fetchOptions);
|
|
@@ -4820,4 +4991,4 @@ var getApiClient = (forServer = null) => {
|
|
|
4820
4991
|
};
|
|
4821
4992
|
|
|
4822
4993
|
export default getApiClient;
|
|
4823
|
-
export { setApiClientId, setApiToken, setCurrentServer, setFetchOptions, setIsMobile, setOnRefreshToken, setOnRefreshTokenError, setRefreshBackend, setRefreshExpiration, setRefreshTenantId, setRefreshToken };
|
|
4994
|
+
export { setApiClientId, setApiToken, setCurrentServer, setFetchOptions, setIsMobile, setOnRefreshToken, setOnRefreshTokenError, setRefreshBackend, setRefreshDomainName, setRefreshExpiration, setRefreshTenantId, setRefreshToken };
|