@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/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' } : {}),
|
|
@@ -3177,6 +3189,70 @@ class ExternalApp {
|
|
|
3177
3189
|
|
|
3178
3190
|
//
|
|
3179
3191
|
|
|
3192
|
+
class MeetingAuthorization {
|
|
3193
|
+
|
|
3194
|
+
|
|
3195
|
+
|
|
3196
|
+
|
|
3197
|
+
|
|
3198
|
+
|
|
3199
|
+
constructor({
|
|
3200
|
+
meetingUuid,
|
|
3201
|
+
uuid,
|
|
3202
|
+
userUuid,
|
|
3203
|
+
userName,
|
|
3204
|
+
} = {}) {
|
|
3205
|
+
this.meetingUuid = meetingUuid;
|
|
3206
|
+
this.uuid = uuid;
|
|
3207
|
+
this.userUuid = userUuid;
|
|
3208
|
+
this.userName = userName;
|
|
3209
|
+
}
|
|
3210
|
+
|
|
3211
|
+
setStatus(status ) {
|
|
3212
|
+
this.status = status;
|
|
3213
|
+
}
|
|
3214
|
+
|
|
3215
|
+
getStatus() {
|
|
3216
|
+
return this.status;
|
|
3217
|
+
}
|
|
3218
|
+
|
|
3219
|
+
static parse(plain ) {
|
|
3220
|
+
const {
|
|
3221
|
+
meeting_uuid: meetingUuid,
|
|
3222
|
+
uuid,
|
|
3223
|
+
guest_uuid: userUuid,
|
|
3224
|
+
guest_name: userName,
|
|
3225
|
+
} = plain;
|
|
3226
|
+
|
|
3227
|
+
return new MeetingAuthorization({
|
|
3228
|
+
meetingUuid,
|
|
3229
|
+
uuid,
|
|
3230
|
+
userUuid,
|
|
3231
|
+
userName,
|
|
3232
|
+
});
|
|
3233
|
+
}
|
|
3234
|
+
|
|
3235
|
+
static parseMany(items ) {
|
|
3236
|
+
if (!items) {
|
|
3237
|
+
return [];
|
|
3238
|
+
}
|
|
3239
|
+
return items.map(MeetingAuthorization.parse);
|
|
3240
|
+
}
|
|
3241
|
+
}
|
|
3242
|
+
|
|
3243
|
+
//
|
|
3244
|
+
|
|
3245
|
+
|
|
3246
|
+
|
|
3247
|
+
|
|
3248
|
+
|
|
3249
|
+
|
|
3250
|
+
|
|
3251
|
+
|
|
3252
|
+
|
|
3253
|
+
|
|
3254
|
+
|
|
3255
|
+
|
|
3180
3256
|
|
|
3181
3257
|
|
|
3182
3258
|
|
|
@@ -3187,6 +3263,7 @@ class ExternalApp {
|
|
|
3187
3263
|
|
|
3188
3264
|
|
|
3189
3265
|
|
|
3266
|
+
|
|
3190
3267
|
|
|
3191
3268
|
|
|
3192
3269
|
class Meeting {
|
|
@@ -3201,6 +3278,8 @@ class Meeting {
|
|
|
3201
3278
|
|
|
3202
3279
|
|
|
3203
3280
|
|
|
3281
|
+
|
|
3282
|
+
|
|
3204
3283
|
|
|
3205
3284
|
static parse(plain ) {
|
|
3206
3285
|
return new Meeting({
|
|
@@ -3213,6 +3292,7 @@ class Meeting {
|
|
|
3213
3292
|
extension: plain.exten,
|
|
3214
3293
|
persistent: plain.persistent,
|
|
3215
3294
|
creationTime: moment__default['default'](plain.creation_time).toDate(),
|
|
3295
|
+
requireAuthorization: plain.require_authorization,
|
|
3216
3296
|
});
|
|
3217
3297
|
}
|
|
3218
3298
|
|
|
@@ -3237,6 +3317,7 @@ class Meeting {
|
|
|
3237
3317
|
extension,
|
|
3238
3318
|
persistent,
|
|
3239
3319
|
creationTime,
|
|
3320
|
+
requireAuthorization,
|
|
3240
3321
|
} = {}) {
|
|
3241
3322
|
this.guestSipAuthorization = guestSipAuthorization;
|
|
3242
3323
|
this.uri = uri;
|
|
@@ -3247,6 +3328,7 @@ class Meeting {
|
|
|
3247
3328
|
this.extension = extension;
|
|
3248
3329
|
this.persistent = persistent;
|
|
3249
3330
|
this.creationTime = creationTime;
|
|
3331
|
+
this.requireAuthorization = requireAuthorization;
|
|
3250
3332
|
|
|
3251
3333
|
// Useful to compare instead of instanceof with minified code
|
|
3252
3334
|
this.type = 'Meeting';
|
|
@@ -3257,8 +3339,32 @@ class Meeting {
|
|
|
3257
3339
|
const [username, secret] = atob(this.guestSipAuthorization).split(':');
|
|
3258
3340
|
return { username, secret };
|
|
3259
3341
|
}
|
|
3342
|
+
|
|
3260
3343
|
}
|
|
3261
3344
|
|
|
3345
|
+
//
|
|
3346
|
+
|
|
3347
|
+
const camelToUnderscore = (key ) => {
|
|
3348
|
+
if (typeof key !== 'string') {
|
|
3349
|
+
throw new Error('Input is not a string');
|
|
3350
|
+
}
|
|
3351
|
+
return key.charAt(0).toLowerCase() + key.substring(1).replace(/([A-Z])/g, '_$1').toLowerCase();
|
|
3352
|
+
};
|
|
3353
|
+
|
|
3354
|
+
//
|
|
3355
|
+
|
|
3356
|
+
const convertKeysFromCamelToUnderscore = (args ) => {
|
|
3357
|
+
if (!args || typeof args !== 'object' || Array.isArray(args)) {
|
|
3358
|
+
throw new Error('Input is not an object');
|
|
3359
|
+
}
|
|
3360
|
+
|
|
3361
|
+
return Object.keys(args).reduce((acc, key) => {
|
|
3362
|
+
acc[camelToUnderscore(key)] = typeof args[key] === 'object' && !Array.isArray(args[key])
|
|
3363
|
+
? convertKeysFromCamelToUnderscore(args[key]) : args[key];
|
|
3364
|
+
return acc;
|
|
3365
|
+
}, {});
|
|
3366
|
+
};
|
|
3367
|
+
|
|
3262
3368
|
/* */
|
|
3263
3369
|
|
|
3264
3370
|
var confdMethods = (client , baseUrl ) => ({
|
|
@@ -3327,8 +3433,18 @@ var confdMethods = (client , baseUrl ) => ({
|
|
|
3327
3433
|
getMyMeetings: () =>
|
|
3328
3434
|
client.get(`${baseUrl}/users/me/meetings`).then(response => Meeting.parseMany(response.items)),
|
|
3329
3435
|
|
|
3330
|
-
createMyMeeting: (
|
|
3331
|
-
client
|
|
3436
|
+
createMyMeeting: (args ) =>
|
|
3437
|
+
client
|
|
3438
|
+
.post(`${baseUrl}/users/me/meetings`, convertKeysFromCamelToUnderscore(args))
|
|
3439
|
+
.then(Meeting.parse),
|
|
3440
|
+
|
|
3441
|
+
updateMyMeeting: (meetingUuid , data ) =>
|
|
3442
|
+
client.put(
|
|
3443
|
+
`${baseUrl}/users/me/meetings/${meetingUuid}`,
|
|
3444
|
+
convertKeysFromCamelToUnderscore(data),
|
|
3445
|
+
null,
|
|
3446
|
+
ApiRequester.successResponseParser,
|
|
3447
|
+
),
|
|
3332
3448
|
|
|
3333
3449
|
deleteMyMeeting: (meetingUuid ) =>
|
|
3334
3450
|
client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
|
|
@@ -3336,8 +3452,36 @@ var confdMethods = (client , baseUrl ) => ({
|
|
|
3336
3452
|
getMeeting: (meetingUuid ) =>
|
|
3337
3453
|
client.get(`${baseUrl}/meetings/${meetingUuid}`, null).then(Meeting.parse),
|
|
3338
3454
|
|
|
3455
|
+
meetingAuthorizations: (meetingUuid ) =>
|
|
3456
|
+
client.get(`${baseUrl}/users/me/meetings/${meetingUuid}/authorizations`, null).then(MeetingAuthorization.parseMany),
|
|
3457
|
+
|
|
3458
|
+
meetingAuthorizationReject: (meetingUuid , authorizationUuid ) =>
|
|
3459
|
+
client.put(
|
|
3460
|
+
`${baseUrl}/users/me/meetings/${meetingUuid}/authorizations/${authorizationUuid}/reject`,
|
|
3461
|
+
{},
|
|
3462
|
+
null,
|
|
3463
|
+
ApiRequester.successResponseParser,
|
|
3464
|
+
),
|
|
3465
|
+
|
|
3466
|
+
meetingAuthorizationAccept: (meetingUuid , authorizationUuid ) =>
|
|
3467
|
+
client.put(
|
|
3468
|
+
`${baseUrl}/users/me/meetings/${meetingUuid}/authorizations/${authorizationUuid}/accept`,
|
|
3469
|
+
{},
|
|
3470
|
+
null,
|
|
3471
|
+
ApiRequester.successResponseParser,
|
|
3472
|
+
),
|
|
3473
|
+
|
|
3339
3474
|
guestGetMeeting: (meetingUuid ) =>
|
|
3340
3475
|
client.get(`${baseUrl}/guests/me/meetings/${meetingUuid}`, null).then(Meeting.parse),
|
|
3476
|
+
|
|
3477
|
+
guestAuthorizationRequest: (userUuid , meetingUuid , username ) =>
|
|
3478
|
+
client
|
|
3479
|
+
.post(`${baseUrl}/guests/${userUuid}/meetings/${meetingUuid}/authorizations`, { guest_name: username })
|
|
3480
|
+
.then(MeetingAuthorization.parse),
|
|
3481
|
+
|
|
3482
|
+
guestAuthorizationCheck: (userUuid , meetingUuid , authorizationUuid ) =>
|
|
3483
|
+
client.get(`${baseUrl}/guests/${userUuid}/meetings/${meetingUuid}/authorizations/${authorizationUuid}`, null),
|
|
3484
|
+
|
|
3341
3485
|
});
|
|
3342
3486
|
|
|
3343
3487
|
//
|
|
@@ -4213,6 +4357,14 @@ var calldMethods = (client , baseUrl ) => ({
|
|
|
4213
4357
|
getMeetingParticipantsAsUser: async (meetingUuid ) =>
|
|
4214
4358
|
client.get(`${baseUrl}/users/me/meetings/${meetingUuid}/participants`),
|
|
4215
4359
|
|
|
4360
|
+
banMeetingParticipant: (meetingUuid , participantUuid ) =>
|
|
4361
|
+
client.delete(
|
|
4362
|
+
`${baseUrl}/users/me/meetings/${meetingUuid}/participants/${participantUuid}`,
|
|
4363
|
+
null,
|
|
4364
|
+
null,
|
|
4365
|
+
ApiRequester.successResponseParser,
|
|
4366
|
+
),
|
|
4367
|
+
|
|
4216
4368
|
listTrunks: () => client.get(`${baseUrl}/trunks`),
|
|
4217
4369
|
|
|
4218
4370
|
mute: (callId ) =>
|
|
@@ -4590,6 +4742,7 @@ class ApiClient {
|
|
|
4590
4742
|
|
|
4591
4743
|
|
|
4592
4744
|
|
|
4745
|
+
|
|
4593
4746
|
|
|
4594
4747
|
|
|
4595
4748
|
|
|
@@ -4631,6 +4784,7 @@ class ApiClient {
|
|
|
4631
4784
|
refreshToken: this.refreshToken,
|
|
4632
4785
|
refreshBackend: this.refreshBackend,
|
|
4633
4786
|
refreshTenantId: this.refreshTenantId,
|
|
4787
|
+
refreshDomainName: this.refreshDomainName,
|
|
4634
4788
|
refreshExpiration: this.refreshExpiration,
|
|
4635
4789
|
isMobile: this.isMobile,
|
|
4636
4790
|
});
|
|
@@ -4646,6 +4800,7 @@ class ApiClient {
|
|
|
4646
4800
|
this.refreshExpiration,
|
|
4647
4801
|
this.isMobile,
|
|
4648
4802
|
this.refreshTenantId,
|
|
4803
|
+
this.refreshDomainName,
|
|
4649
4804
|
);
|
|
4650
4805
|
|
|
4651
4806
|
logger.info('token refreshed', { token: session.token });
|
|
@@ -4699,9 +4854,14 @@ class ApiClient {
|
|
|
4699
4854
|
}
|
|
4700
4855
|
|
|
4701
4856
|
setRefreshTenantId(tenantId ) {
|
|
4857
|
+
console.warn('Use of `setRefreshTenantId` is deprecated, use `setRefreshDomainName` instead');
|
|
4702
4858
|
this.refreshTenantId = tenantId;
|
|
4703
4859
|
}
|
|
4704
4860
|
|
|
4861
|
+
setRefreshDomainName(domainName ) {
|
|
4862
|
+
this.refreshDomainName = domainName;
|
|
4863
|
+
}
|
|
4864
|
+
|
|
4705
4865
|
setIsMobile(isMobile ) {
|
|
4706
4866
|
this.isMobile = isMobile;
|
|
4707
4867
|
}
|
|
@@ -4726,6 +4886,7 @@ global.wazoClientId = global.wazoClientId || {};
|
|
|
4726
4886
|
global.wazoClientToken = global.wazoClientToken || {};
|
|
4727
4887
|
global.wazoRefreshToken = global.wazoRefreshToken || {};
|
|
4728
4888
|
global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
|
|
4889
|
+
global.wazoRefreshDomainName = global.wazoRefreshDomainName || {};
|
|
4729
4890
|
global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
|
|
4730
4891
|
global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
|
|
4731
4892
|
global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
|
|
@@ -4735,6 +4896,7 @@ global.wazoFetchOptions = global.wazoFetchOptions || {};
|
|
|
4735
4896
|
|
|
4736
4897
|
const fillClient = (apiClient ) => {
|
|
4737
4898
|
const { server, token, clientId } = apiClient.client;
|
|
4899
|
+
const tenantId = global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId;
|
|
4738
4900
|
|
|
4739
4901
|
// try with null server when dealing with non-related server info
|
|
4740
4902
|
apiClient.setToken(global.wazoClientToken[server] || global.wazoClientToken[null] || token);
|
|
@@ -4743,8 +4905,12 @@ const fillClient = (apiClient ) => {
|
|
|
4743
4905
|
|
|
4744
4906
|
apiClient.setRefreshToken(global.wazoRefreshToken[server] || global.wazoRefreshToken[null] || apiClient.refreshToken);
|
|
4745
4907
|
|
|
4746
|
-
|
|
4747
|
-
|
|
4908
|
+
if (tenantId) {
|
|
4909
|
+
apiClient.setRefreshTenantId(tenantId);
|
|
4910
|
+
}
|
|
4911
|
+
|
|
4912
|
+
apiClient.setRefreshDomainName(
|
|
4913
|
+
global.wazoRefreshDomainName[server] || global.wazoRefreshDomainName[null] || apiClient.refreshDomainName,
|
|
4748
4914
|
);
|
|
4749
4915
|
|
|
4750
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' } : {}),
|
|
@@ -2633,6 +2645,70 @@ class ExternalApp {
|
|
|
2633
2645
|
|
|
2634
2646
|
//
|
|
2635
2647
|
|
|
2648
|
+
class MeetingAuthorization {
|
|
2649
|
+
|
|
2650
|
+
|
|
2651
|
+
|
|
2652
|
+
|
|
2653
|
+
|
|
2654
|
+
|
|
2655
|
+
constructor({
|
|
2656
|
+
meetingUuid,
|
|
2657
|
+
uuid,
|
|
2658
|
+
userUuid,
|
|
2659
|
+
userName,
|
|
2660
|
+
} = {}) {
|
|
2661
|
+
this.meetingUuid = meetingUuid;
|
|
2662
|
+
this.uuid = uuid;
|
|
2663
|
+
this.userUuid = userUuid;
|
|
2664
|
+
this.userName = userName;
|
|
2665
|
+
}
|
|
2666
|
+
|
|
2667
|
+
setStatus(status ) {
|
|
2668
|
+
this.status = status;
|
|
2669
|
+
}
|
|
2670
|
+
|
|
2671
|
+
getStatus() {
|
|
2672
|
+
return this.status;
|
|
2673
|
+
}
|
|
2674
|
+
|
|
2675
|
+
static parse(plain ) {
|
|
2676
|
+
const {
|
|
2677
|
+
meeting_uuid: meetingUuid,
|
|
2678
|
+
uuid,
|
|
2679
|
+
guest_uuid: userUuid,
|
|
2680
|
+
guest_name: userName,
|
|
2681
|
+
} = plain;
|
|
2682
|
+
|
|
2683
|
+
return new MeetingAuthorization({
|
|
2684
|
+
meetingUuid,
|
|
2685
|
+
uuid,
|
|
2686
|
+
userUuid,
|
|
2687
|
+
userName,
|
|
2688
|
+
});
|
|
2689
|
+
}
|
|
2690
|
+
|
|
2691
|
+
static parseMany(items ) {
|
|
2692
|
+
if (!items) {
|
|
2693
|
+
return [];
|
|
2694
|
+
}
|
|
2695
|
+
return items.map(MeetingAuthorization.parse);
|
|
2696
|
+
}
|
|
2697
|
+
}
|
|
2698
|
+
|
|
2699
|
+
//
|
|
2700
|
+
|
|
2701
|
+
|
|
2702
|
+
|
|
2703
|
+
|
|
2704
|
+
|
|
2705
|
+
|
|
2706
|
+
|
|
2707
|
+
|
|
2708
|
+
|
|
2709
|
+
|
|
2710
|
+
|
|
2711
|
+
|
|
2636
2712
|
|
|
2637
2713
|
|
|
2638
2714
|
|
|
@@ -2643,6 +2719,7 @@ class ExternalApp {
|
|
|
2643
2719
|
|
|
2644
2720
|
|
|
2645
2721
|
|
|
2722
|
+
|
|
2646
2723
|
|
|
2647
2724
|
|
|
2648
2725
|
class Meeting {
|
|
@@ -2657,6 +2734,8 @@ class Meeting {
|
|
|
2657
2734
|
|
|
2658
2735
|
|
|
2659
2736
|
|
|
2737
|
+
|
|
2738
|
+
|
|
2660
2739
|
|
|
2661
2740
|
static parse(plain ) {
|
|
2662
2741
|
return new Meeting({
|
|
@@ -2669,6 +2748,7 @@ class Meeting {
|
|
|
2669
2748
|
extension: plain.exten,
|
|
2670
2749
|
persistent: plain.persistent,
|
|
2671
2750
|
creationTime: moment__default['default'](plain.creation_time).toDate(),
|
|
2751
|
+
requireAuthorization: plain.require_authorization,
|
|
2672
2752
|
});
|
|
2673
2753
|
}
|
|
2674
2754
|
|
|
@@ -2693,6 +2773,7 @@ class Meeting {
|
|
|
2693
2773
|
extension,
|
|
2694
2774
|
persistent,
|
|
2695
2775
|
creationTime,
|
|
2776
|
+
requireAuthorization,
|
|
2696
2777
|
} = {}) {
|
|
2697
2778
|
this.guestSipAuthorization = guestSipAuthorization;
|
|
2698
2779
|
this.uri = uri;
|
|
@@ -2703,6 +2784,7 @@ class Meeting {
|
|
|
2703
2784
|
this.extension = extension;
|
|
2704
2785
|
this.persistent = persistent;
|
|
2705
2786
|
this.creationTime = creationTime;
|
|
2787
|
+
this.requireAuthorization = requireAuthorization;
|
|
2706
2788
|
|
|
2707
2789
|
// Useful to compare instead of instanceof with minified code
|
|
2708
2790
|
this.type = 'Meeting';
|
|
@@ -2713,8 +2795,32 @@ class Meeting {
|
|
|
2713
2795
|
const [username, secret] = atob(this.guestSipAuthorization).split(':');
|
|
2714
2796
|
return { username, secret };
|
|
2715
2797
|
}
|
|
2798
|
+
|
|
2716
2799
|
}
|
|
2717
2800
|
|
|
2801
|
+
//
|
|
2802
|
+
|
|
2803
|
+
const camelToUnderscore = (key ) => {
|
|
2804
|
+
if (typeof key !== 'string') {
|
|
2805
|
+
throw new Error('Input is not a string');
|
|
2806
|
+
}
|
|
2807
|
+
return key.charAt(0).toLowerCase() + key.substring(1).replace(/([A-Z])/g, '_$1').toLowerCase();
|
|
2808
|
+
};
|
|
2809
|
+
|
|
2810
|
+
//
|
|
2811
|
+
|
|
2812
|
+
const convertKeysFromCamelToUnderscore = (args ) => {
|
|
2813
|
+
if (!args || typeof args !== 'object' || Array.isArray(args)) {
|
|
2814
|
+
throw new Error('Input is not an object');
|
|
2815
|
+
}
|
|
2816
|
+
|
|
2817
|
+
return Object.keys(args).reduce((acc, key) => {
|
|
2818
|
+
acc[camelToUnderscore(key)] = typeof args[key] === 'object' && !Array.isArray(args[key])
|
|
2819
|
+
? convertKeysFromCamelToUnderscore(args[key]) : args[key];
|
|
2820
|
+
return acc;
|
|
2821
|
+
}, {});
|
|
2822
|
+
};
|
|
2823
|
+
|
|
2718
2824
|
/* */
|
|
2719
2825
|
|
|
2720
2826
|
var confdMethods = (client , baseUrl ) => ({
|
|
@@ -2783,8 +2889,18 @@ var confdMethods = (client , baseUrl ) => ({
|
|
|
2783
2889
|
getMyMeetings: () =>
|
|
2784
2890
|
client.get(`${baseUrl}/users/me/meetings`).then(response => Meeting.parseMany(response.items)),
|
|
2785
2891
|
|
|
2786
|
-
createMyMeeting: (
|
|
2787
|
-
client
|
|
2892
|
+
createMyMeeting: (args ) =>
|
|
2893
|
+
client
|
|
2894
|
+
.post(`${baseUrl}/users/me/meetings`, convertKeysFromCamelToUnderscore(args))
|
|
2895
|
+
.then(Meeting.parse),
|
|
2896
|
+
|
|
2897
|
+
updateMyMeeting: (meetingUuid , data ) =>
|
|
2898
|
+
client.put(
|
|
2899
|
+
`${baseUrl}/users/me/meetings/${meetingUuid}`,
|
|
2900
|
+
convertKeysFromCamelToUnderscore(data),
|
|
2901
|
+
null,
|
|
2902
|
+
ApiRequester.successResponseParser,
|
|
2903
|
+
),
|
|
2788
2904
|
|
|
2789
2905
|
deleteMyMeeting: (meetingUuid ) =>
|
|
2790
2906
|
client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
|
|
@@ -2792,8 +2908,36 @@ var confdMethods = (client , baseUrl ) => ({
|
|
|
2792
2908
|
getMeeting: (meetingUuid ) =>
|
|
2793
2909
|
client.get(`${baseUrl}/meetings/${meetingUuid}`, null).then(Meeting.parse),
|
|
2794
2910
|
|
|
2911
|
+
meetingAuthorizations: (meetingUuid ) =>
|
|
2912
|
+
client.get(`${baseUrl}/users/me/meetings/${meetingUuid}/authorizations`, null).then(MeetingAuthorization.parseMany),
|
|
2913
|
+
|
|
2914
|
+
meetingAuthorizationReject: (meetingUuid , authorizationUuid ) =>
|
|
2915
|
+
client.put(
|
|
2916
|
+
`${baseUrl}/users/me/meetings/${meetingUuid}/authorizations/${authorizationUuid}/reject`,
|
|
2917
|
+
{},
|
|
2918
|
+
null,
|
|
2919
|
+
ApiRequester.successResponseParser,
|
|
2920
|
+
),
|
|
2921
|
+
|
|
2922
|
+
meetingAuthorizationAccept: (meetingUuid , authorizationUuid ) =>
|
|
2923
|
+
client.put(
|
|
2924
|
+
`${baseUrl}/users/me/meetings/${meetingUuid}/authorizations/${authorizationUuid}/accept`,
|
|
2925
|
+
{},
|
|
2926
|
+
null,
|
|
2927
|
+
ApiRequester.successResponseParser,
|
|
2928
|
+
),
|
|
2929
|
+
|
|
2795
2930
|
guestGetMeeting: (meetingUuid ) =>
|
|
2796
2931
|
client.get(`${baseUrl}/guests/me/meetings/${meetingUuid}`, null).then(Meeting.parse),
|
|
2932
|
+
|
|
2933
|
+
guestAuthorizationRequest: (userUuid , meetingUuid , username ) =>
|
|
2934
|
+
client
|
|
2935
|
+
.post(`${baseUrl}/guests/${userUuid}/meetings/${meetingUuid}/authorizations`, { guest_name: username })
|
|
2936
|
+
.then(MeetingAuthorization.parse),
|
|
2937
|
+
|
|
2938
|
+
guestAuthorizationCheck: (userUuid , meetingUuid , authorizationUuid ) =>
|
|
2939
|
+
client.get(`${baseUrl}/guests/${userUuid}/meetings/${meetingUuid}/authorizations/${authorizationUuid}`, null),
|
|
2940
|
+
|
|
2797
2941
|
});
|
|
2798
2942
|
|
|
2799
2943
|
//
|
|
@@ -4215,6 +4359,14 @@ var calldMethods = (client , baseUrl ) => ({
|
|
|
4215
4359
|
getMeetingParticipantsAsUser: async (meetingUuid ) =>
|
|
4216
4360
|
client.get(`${baseUrl}/users/me/meetings/${meetingUuid}/participants`),
|
|
4217
4361
|
|
|
4362
|
+
banMeetingParticipant: (meetingUuid , participantUuid ) =>
|
|
4363
|
+
client.delete(
|
|
4364
|
+
`${baseUrl}/users/me/meetings/${meetingUuid}/participants/${participantUuid}`,
|
|
4365
|
+
null,
|
|
4366
|
+
null,
|
|
4367
|
+
ApiRequester.successResponseParser,
|
|
4368
|
+
),
|
|
4369
|
+
|
|
4218
4370
|
listTrunks: () => client.get(`${baseUrl}/trunks`),
|
|
4219
4371
|
|
|
4220
4372
|
mute: (callId ) =>
|
|
@@ -4592,6 +4744,7 @@ class ApiClient {
|
|
|
4592
4744
|
|
|
4593
4745
|
|
|
4594
4746
|
|
|
4747
|
+
|
|
4595
4748
|
|
|
4596
4749
|
|
|
4597
4750
|
|
|
@@ -4633,6 +4786,7 @@ class ApiClient {
|
|
|
4633
4786
|
refreshToken: this.refreshToken,
|
|
4634
4787
|
refreshBackend: this.refreshBackend,
|
|
4635
4788
|
refreshTenantId: this.refreshTenantId,
|
|
4789
|
+
refreshDomainName: this.refreshDomainName,
|
|
4636
4790
|
refreshExpiration: this.refreshExpiration,
|
|
4637
4791
|
isMobile: this.isMobile,
|
|
4638
4792
|
});
|
|
@@ -4648,6 +4802,7 @@ class ApiClient {
|
|
|
4648
4802
|
this.refreshExpiration,
|
|
4649
4803
|
this.isMobile,
|
|
4650
4804
|
this.refreshTenantId,
|
|
4805
|
+
this.refreshDomainName,
|
|
4651
4806
|
);
|
|
4652
4807
|
|
|
4653
4808
|
logger.info('token refreshed', { token: session.token });
|
|
@@ -4701,9 +4856,14 @@ class ApiClient {
|
|
|
4701
4856
|
}
|
|
4702
4857
|
|
|
4703
4858
|
setRefreshTenantId(tenantId ) {
|
|
4859
|
+
console.warn('Use of `setRefreshTenantId` is deprecated, use `setRefreshDomainName` instead');
|
|
4704
4860
|
this.refreshTenantId = tenantId;
|
|
4705
4861
|
}
|
|
4706
4862
|
|
|
4863
|
+
setRefreshDomainName(domainName ) {
|
|
4864
|
+
this.refreshDomainName = domainName;
|
|
4865
|
+
}
|
|
4866
|
+
|
|
4707
4867
|
setIsMobile(isMobile ) {
|
|
4708
4868
|
this.isMobile = isMobile;
|
|
4709
4869
|
}
|
|
@@ -4728,6 +4888,7 @@ global.wazoClientId = global.wazoClientId || {};
|
|
|
4728
4888
|
global.wazoClientToken = global.wazoClientToken || {};
|
|
4729
4889
|
global.wazoRefreshToken = global.wazoRefreshToken || {};
|
|
4730
4890
|
global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
|
|
4891
|
+
global.wazoRefreshDomainName = global.wazoRefreshDomainName || {};
|
|
4731
4892
|
global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
|
|
4732
4893
|
global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
|
|
4733
4894
|
global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
|
|
@@ -4752,9 +4913,14 @@ const setRefreshToken = (newRefreshToken , forServer = null) =>
|
|
|
4752
4913
|
};
|
|
4753
4914
|
|
|
4754
4915
|
const setRefreshTenantId = (refreshTenantId , forServer = null) => {
|
|
4916
|
+
console.warn('Use of `setRefreshTenantId` is deprecated, please use `setRefreshDomainName` instead');
|
|
4755
4917
|
global.wazoRefreshTenantId[forServer] = refreshTenantId;
|
|
4756
4918
|
};
|
|
4757
4919
|
|
|
4920
|
+
const setRefreshDomainName = (refreshDomainName , forServer = null) => {
|
|
4921
|
+
global.wazoRefreshDomainName[forServer] = refreshDomainName;
|
|
4922
|
+
};
|
|
4923
|
+
|
|
4758
4924
|
const setOnRefreshToken = (onRefreshToken , forServer = null) => {
|
|
4759
4925
|
global.wazoOnRefreshToken[forServer] = onRefreshToken;
|
|
4760
4926
|
};
|
|
@@ -4781,6 +4947,7 @@ const setFetchOptions = (fetchOptions , forServer = null) => {
|
|
|
4781
4947
|
|
|
4782
4948
|
const fillClient = (apiClient ) => {
|
|
4783
4949
|
const { server, token, clientId } = apiClient.client;
|
|
4950
|
+
const tenantId = global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId;
|
|
4784
4951
|
|
|
4785
4952
|
// try with null server when dealing with non-related server info
|
|
4786
4953
|
apiClient.setToken(global.wazoClientToken[server] || global.wazoClientToken[null] || token);
|
|
@@ -4789,8 +4956,12 @@ const fillClient = (apiClient ) => {
|
|
|
4789
4956
|
|
|
4790
4957
|
apiClient.setRefreshToken(global.wazoRefreshToken[server] || global.wazoRefreshToken[null] || apiClient.refreshToken);
|
|
4791
4958
|
|
|
4792
|
-
|
|
4793
|
-
|
|
4959
|
+
if (tenantId) {
|
|
4960
|
+
apiClient.setRefreshTenantId(tenantId);
|
|
4961
|
+
}
|
|
4962
|
+
|
|
4963
|
+
apiClient.setRefreshDomainName(
|
|
4964
|
+
global.wazoRefreshDomainName[server] || global.wazoRefreshDomainName[null] || apiClient.refreshDomainName,
|
|
4794
4965
|
);
|
|
4795
4966
|
|
|
4796
4967
|
apiClient.setFetchOptions(global.wazoFetchOptions[server] || global.wazoFetchOptions[null] || apiClient.fetchOptions);
|
|
@@ -4836,6 +5007,7 @@ exports.setIsMobile = setIsMobile;
|
|
|
4836
5007
|
exports.setOnRefreshToken = setOnRefreshToken;
|
|
4837
5008
|
exports.setOnRefreshTokenError = setOnRefreshTokenError;
|
|
4838
5009
|
exports.setRefreshBackend = setRefreshBackend;
|
|
5010
|
+
exports.setRefreshDomainName = setRefreshDomainName;
|
|
4839
5011
|
exports.setRefreshExpiration = setRefreshExpiration;
|
|
4840
5012
|
exports.setRefreshTenantId = setRefreshTenantId;
|
|
4841
5013
|
exports.setRefreshToken = setRefreshToken;
|