@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
|
@@ -2430,6 +2430,7 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2430
2430
|
|
|
2431
2431
|
|
|
2432
2432
|
|
|
2433
|
+
|
|
2433
2434
|
) {
|
|
2434
2435
|
const body = {
|
|
2435
2436
|
backend: params.backend || DEFAULT_BACKEND_USER,
|
|
@@ -2450,9 +2451,14 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2450
2451
|
}
|
|
2451
2452
|
|
|
2452
2453
|
if (params.tenantId) {
|
|
2454
|
+
console.warn('Use of `tenantId` is deprecated when calling logIn() method, use `domainName` instead.');
|
|
2453
2455
|
body.tenant_id = params.tenantId;
|
|
2454
2456
|
}
|
|
2455
2457
|
|
|
2458
|
+
if (params.domainName) {
|
|
2459
|
+
body.domain_name = params.domainName;
|
|
2460
|
+
}
|
|
2461
|
+
|
|
2456
2462
|
return client.post(`${baseUrl}/token`, body, headers).then(response => Session.parse(response));
|
|
2457
2463
|
},
|
|
2458
2464
|
|
|
@@ -2465,6 +2471,7 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2465
2471
|
expiration ,
|
|
2466
2472
|
isMobile = false,
|
|
2467
2473
|
tenantId ,
|
|
2474
|
+
domainName ,
|
|
2468
2475
|
) => {
|
|
2469
2476
|
const body = {
|
|
2470
2477
|
backend: backend || DEFAULT_BACKEND_USER,
|
|
@@ -2474,9 +2481,14 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2474
2481
|
};
|
|
2475
2482
|
|
|
2476
2483
|
if (tenantId) {
|
|
2484
|
+
console.warn('Use of `tenantId` is deprecated when calling refreshToken() method, use `domainName` instead.');
|
|
2477
2485
|
body.tenant_id = tenantId;
|
|
2478
2486
|
}
|
|
2479
2487
|
|
|
2488
|
+
if (domainName) {
|
|
2489
|
+
body.domain_name = domainName;
|
|
2490
|
+
}
|
|
2491
|
+
|
|
2480
2492
|
const headers = {
|
|
2481
2493
|
'Content-Type': 'application/json',
|
|
2482
2494
|
...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),
|
|
@@ -2846,6 +2858,70 @@ class ExternalApp {
|
|
|
2846
2858
|
|
|
2847
2859
|
//
|
|
2848
2860
|
|
|
2861
|
+
class MeetingAuthorization {
|
|
2862
|
+
|
|
2863
|
+
|
|
2864
|
+
|
|
2865
|
+
|
|
2866
|
+
|
|
2867
|
+
|
|
2868
|
+
constructor({
|
|
2869
|
+
meetingUuid,
|
|
2870
|
+
uuid,
|
|
2871
|
+
userUuid,
|
|
2872
|
+
userName,
|
|
2873
|
+
} = {}) {
|
|
2874
|
+
this.meetingUuid = meetingUuid;
|
|
2875
|
+
this.uuid = uuid;
|
|
2876
|
+
this.userUuid = userUuid;
|
|
2877
|
+
this.userName = userName;
|
|
2878
|
+
}
|
|
2879
|
+
|
|
2880
|
+
setStatus(status ) {
|
|
2881
|
+
this.status = status;
|
|
2882
|
+
}
|
|
2883
|
+
|
|
2884
|
+
getStatus() {
|
|
2885
|
+
return this.status;
|
|
2886
|
+
}
|
|
2887
|
+
|
|
2888
|
+
static parse(plain ) {
|
|
2889
|
+
const {
|
|
2890
|
+
meeting_uuid: meetingUuid,
|
|
2891
|
+
uuid,
|
|
2892
|
+
guest_uuid: userUuid,
|
|
2893
|
+
guest_name: userName,
|
|
2894
|
+
} = plain;
|
|
2895
|
+
|
|
2896
|
+
return new MeetingAuthorization({
|
|
2897
|
+
meetingUuid,
|
|
2898
|
+
uuid,
|
|
2899
|
+
userUuid,
|
|
2900
|
+
userName,
|
|
2901
|
+
});
|
|
2902
|
+
}
|
|
2903
|
+
|
|
2904
|
+
static parseMany(items ) {
|
|
2905
|
+
if (!items) {
|
|
2906
|
+
return [];
|
|
2907
|
+
}
|
|
2908
|
+
return items.map(MeetingAuthorization.parse);
|
|
2909
|
+
}
|
|
2910
|
+
}
|
|
2911
|
+
|
|
2912
|
+
//
|
|
2913
|
+
|
|
2914
|
+
|
|
2915
|
+
|
|
2916
|
+
|
|
2917
|
+
|
|
2918
|
+
|
|
2919
|
+
|
|
2920
|
+
|
|
2921
|
+
|
|
2922
|
+
|
|
2923
|
+
|
|
2924
|
+
|
|
2849
2925
|
|
|
2850
2926
|
|
|
2851
2927
|
|
|
@@ -2856,6 +2932,7 @@ class ExternalApp {
|
|
|
2856
2932
|
|
|
2857
2933
|
|
|
2858
2934
|
|
|
2935
|
+
|
|
2859
2936
|
|
|
2860
2937
|
|
|
2861
2938
|
class Meeting {
|
|
@@ -2870,6 +2947,8 @@ class Meeting {
|
|
|
2870
2947
|
|
|
2871
2948
|
|
|
2872
2949
|
|
|
2950
|
+
|
|
2951
|
+
|
|
2873
2952
|
|
|
2874
2953
|
static parse(plain ) {
|
|
2875
2954
|
return new Meeting({
|
|
@@ -2882,6 +2961,7 @@ class Meeting {
|
|
|
2882
2961
|
extension: plain.exten,
|
|
2883
2962
|
persistent: plain.persistent,
|
|
2884
2963
|
creationTime: moment__default['default'](plain.creation_time).toDate(),
|
|
2964
|
+
requireAuthorization: plain.require_authorization,
|
|
2885
2965
|
});
|
|
2886
2966
|
}
|
|
2887
2967
|
|
|
@@ -2906,6 +2986,7 @@ class Meeting {
|
|
|
2906
2986
|
extension,
|
|
2907
2987
|
persistent,
|
|
2908
2988
|
creationTime,
|
|
2989
|
+
requireAuthorization,
|
|
2909
2990
|
} = {}) {
|
|
2910
2991
|
this.guestSipAuthorization = guestSipAuthorization;
|
|
2911
2992
|
this.uri = uri;
|
|
@@ -2916,6 +2997,7 @@ class Meeting {
|
|
|
2916
2997
|
this.extension = extension;
|
|
2917
2998
|
this.persistent = persistent;
|
|
2918
2999
|
this.creationTime = creationTime;
|
|
3000
|
+
this.requireAuthorization = requireAuthorization;
|
|
2919
3001
|
|
|
2920
3002
|
// Useful to compare instead of instanceof with minified code
|
|
2921
3003
|
this.type = 'Meeting';
|
|
@@ -2926,8 +3008,32 @@ class Meeting {
|
|
|
2926
3008
|
const [username, secret] = atob(this.guestSipAuthorization).split(':');
|
|
2927
3009
|
return { username, secret };
|
|
2928
3010
|
}
|
|
3011
|
+
|
|
2929
3012
|
}
|
|
2930
3013
|
|
|
3014
|
+
//
|
|
3015
|
+
|
|
3016
|
+
const camelToUnderscore = (key ) => {
|
|
3017
|
+
if (typeof key !== 'string') {
|
|
3018
|
+
throw new Error('Input is not a string');
|
|
3019
|
+
}
|
|
3020
|
+
return key.charAt(0).toLowerCase() + key.substring(1).replace(/([A-Z])/g, '_$1').toLowerCase();
|
|
3021
|
+
};
|
|
3022
|
+
|
|
3023
|
+
//
|
|
3024
|
+
|
|
3025
|
+
const convertKeysFromCamelToUnderscore = (args ) => {
|
|
3026
|
+
if (!args || typeof args !== 'object' || Array.isArray(args)) {
|
|
3027
|
+
throw new Error('Input is not an object');
|
|
3028
|
+
}
|
|
3029
|
+
|
|
3030
|
+
return Object.keys(args).reduce((acc, key) => {
|
|
3031
|
+
acc[camelToUnderscore(key)] = typeof args[key] === 'object' && !Array.isArray(args[key])
|
|
3032
|
+
? convertKeysFromCamelToUnderscore(args[key]) : args[key];
|
|
3033
|
+
return acc;
|
|
3034
|
+
}, {});
|
|
3035
|
+
};
|
|
3036
|
+
|
|
2931
3037
|
/* */
|
|
2932
3038
|
|
|
2933
3039
|
var confdMethods = (client , baseUrl ) => ({
|
|
@@ -2996,8 +3102,18 @@ var confdMethods = (client , baseUrl ) => ({
|
|
|
2996
3102
|
getMyMeetings: () =>
|
|
2997
3103
|
client.get(`${baseUrl}/users/me/meetings`).then(response => Meeting.parseMany(response.items)),
|
|
2998
3104
|
|
|
2999
|
-
createMyMeeting: (
|
|
3000
|
-
client
|
|
3105
|
+
createMyMeeting: (args ) =>
|
|
3106
|
+
client
|
|
3107
|
+
.post(`${baseUrl}/users/me/meetings`, convertKeysFromCamelToUnderscore(args))
|
|
3108
|
+
.then(Meeting.parse),
|
|
3109
|
+
|
|
3110
|
+
updateMyMeeting: (meetingUuid , data ) =>
|
|
3111
|
+
client.put(
|
|
3112
|
+
`${baseUrl}/users/me/meetings/${meetingUuid}`,
|
|
3113
|
+
convertKeysFromCamelToUnderscore(data),
|
|
3114
|
+
null,
|
|
3115
|
+
ApiRequester.successResponseParser,
|
|
3116
|
+
),
|
|
3001
3117
|
|
|
3002
3118
|
deleteMyMeeting: (meetingUuid ) =>
|
|
3003
3119
|
client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
|
|
@@ -3005,8 +3121,36 @@ var confdMethods = (client , baseUrl ) => ({
|
|
|
3005
3121
|
getMeeting: (meetingUuid ) =>
|
|
3006
3122
|
client.get(`${baseUrl}/meetings/${meetingUuid}`, null).then(Meeting.parse),
|
|
3007
3123
|
|
|
3124
|
+
meetingAuthorizations: (meetingUuid ) =>
|
|
3125
|
+
client.get(`${baseUrl}/users/me/meetings/${meetingUuid}/authorizations`, null).then(MeetingAuthorization.parseMany),
|
|
3126
|
+
|
|
3127
|
+
meetingAuthorizationReject: (meetingUuid , authorizationUuid ) =>
|
|
3128
|
+
client.put(
|
|
3129
|
+
`${baseUrl}/users/me/meetings/${meetingUuid}/authorizations/${authorizationUuid}/reject`,
|
|
3130
|
+
{},
|
|
3131
|
+
null,
|
|
3132
|
+
ApiRequester.successResponseParser,
|
|
3133
|
+
),
|
|
3134
|
+
|
|
3135
|
+
meetingAuthorizationAccept: (meetingUuid , authorizationUuid ) =>
|
|
3136
|
+
client.put(
|
|
3137
|
+
`${baseUrl}/users/me/meetings/${meetingUuid}/authorizations/${authorizationUuid}/accept`,
|
|
3138
|
+
{},
|
|
3139
|
+
null,
|
|
3140
|
+
ApiRequester.successResponseParser,
|
|
3141
|
+
),
|
|
3142
|
+
|
|
3008
3143
|
guestGetMeeting: (meetingUuid ) =>
|
|
3009
3144
|
client.get(`${baseUrl}/guests/me/meetings/${meetingUuid}`, null).then(Meeting.parse),
|
|
3145
|
+
|
|
3146
|
+
guestAuthorizationRequest: (userUuid , meetingUuid , username ) =>
|
|
3147
|
+
client
|
|
3148
|
+
.post(`${baseUrl}/guests/${userUuid}/meetings/${meetingUuid}/authorizations`, { guest_name: username })
|
|
3149
|
+
.then(MeetingAuthorization.parse),
|
|
3150
|
+
|
|
3151
|
+
guestAuthorizationCheck: (userUuid , meetingUuid , authorizationUuid ) =>
|
|
3152
|
+
client.get(`${baseUrl}/guests/${userUuid}/meetings/${meetingUuid}/authorizations/${authorizationUuid}`, null),
|
|
3153
|
+
|
|
3010
3154
|
});
|
|
3011
3155
|
|
|
3012
3156
|
//
|
|
@@ -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);
|
package/lib/domain/Features.js
CHANGED
|
@@ -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 || {};
|
|
@@ -4737,6 +4898,7 @@ global.wazoFetchOptions = global.wazoFetchOptions || {};
|
|
|
4737
4898
|
|
|
4738
4899
|
const fillClient = (apiClient ) => {
|
|
4739
4900
|
const { server, token, clientId } = apiClient.client;
|
|
4901
|
+
const tenantId = global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId;
|
|
4740
4902
|
|
|
4741
4903
|
// try with null server when dealing with non-related server info
|
|
4742
4904
|
apiClient.setToken(global.wazoClientToken[server] || global.wazoClientToken[null] || token);
|
|
@@ -4745,8 +4907,12 @@ const fillClient = (apiClient ) => {
|
|
|
4745
4907
|
|
|
4746
4908
|
apiClient.setRefreshToken(global.wazoRefreshToken[server] || global.wazoRefreshToken[null] || apiClient.refreshToken);
|
|
4747
4909
|
|
|
4748
|
-
|
|
4749
|
-
|
|
4910
|
+
if (tenantId) {
|
|
4911
|
+
apiClient.setRefreshTenantId(tenantId);
|
|
4912
|
+
}
|
|
4913
|
+
|
|
4914
|
+
apiClient.setRefreshDomainName(
|
|
4915
|
+
global.wazoRefreshDomainName[server] || global.wazoRefreshDomainName[null] || apiClient.refreshDomainName,
|
|
4750
4916
|
);
|
|
4751
4917
|
|
|
4752
4918
|
apiClient.setFetchOptions(global.wazoFetchOptions[server] || global.wazoFetchOptions[null] || apiClient.fetchOptions);
|