@wazo/sdk 0.38.6 → 0.38.9

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.
Files changed (118) hide show
  1. package/dist/wazo-sdk.js +2 -2
  2. package/esm/__tests__/api-client.test.js +142 -2
  3. package/esm/__tests__/web-rtc-client.test.js +249 -28
  4. package/esm/api/calld.js +8 -0
  5. package/esm/api/confd.js +134 -2
  6. package/esm/api-client.js +142 -2
  7. package/esm/checker/Checker.js +205 -25
  8. package/esm/checker/checks/aor.js +142 -2
  9. package/esm/checker/checks/api.js +142 -2
  10. package/esm/checker/checks/index.js +205 -25
  11. package/esm/checker/checks/wazo-websocket.js +2 -0
  12. package/esm/checker/checks/webrtc-transport.js +203 -25
  13. package/esm/checker/checks/webrtc.js +203 -25
  14. package/esm/domain/AdHocAPIConference.js +142 -2
  15. package/esm/domain/Features.js +142 -2
  16. package/esm/domain/Meeting.js +18 -0
  17. package/esm/domain/MeetingAuthorization.js +70 -0
  18. package/esm/domain/Phone/CTIPhone.js +142 -2
  19. package/esm/domain/Phone/WebRTCPhone.js +1 -3
  20. package/esm/domain/__tests__/Meeting.test.js +87 -1
  21. package/esm/domain/__tests__/MeetingAuthorization.test.js +109 -0
  22. package/esm/index.js +249 -31
  23. package/esm/lib/WazoSessionDescriptionHandler.js +22 -1
  24. package/esm/service/CallApi.js +142 -2
  25. package/esm/service/getApiClient.js +142 -2
  26. package/esm/simple/Auth.js +249 -31
  27. package/esm/simple/Configuration.js +249 -31
  28. package/esm/simple/Directory.js +142 -2
  29. package/esm/simple/Phone.js +249 -31
  30. package/esm/simple/Websocket.js +3 -0
  31. package/esm/simple/index.js +249 -31
  32. package/esm/simple/room/LocalParticipant.js +249 -31
  33. package/esm/simple/room/Participant.js +249 -31
  34. package/esm/simple/room/RemoteParticipant.js +249 -31
  35. package/esm/simple/room/Room.js +249 -31
  36. package/esm/simple/room/SipRoom.js +249 -31
  37. package/esm/simple/room/Stream.js +249 -31
  38. package/esm/simple/room/__tests__/Participant.test.js +14745 -0
  39. package/esm/simple/room/__tests__/RemoteParticipant.test.js +249 -31
  40. package/esm/simple/utils.js +249 -31
  41. package/esm/utils/__tests__/object.test.js +57 -0
  42. package/esm/utils/__tests__/sdp.test.js +50 -0
  43. package/esm/utils/__tests__/string.test.js +30 -0
  44. package/esm/utils/object.js +24 -0
  45. package/esm/utils/sdp.js +19 -1
  46. package/esm/utils/string.js +10 -0
  47. package/esm/web-rtc-client.js +203 -25
  48. package/esm/websocket-client.js +3 -1
  49. package/lib/__tests__/api-client.test.js +142 -2
  50. package/lib/__tests__/web-rtc-client.test.js +249 -28
  51. package/lib/api/calld.js +8 -0
  52. package/lib/api/confd.js +134 -2
  53. package/lib/api-client.js +142 -2
  54. package/lib/checker/Checker.js +205 -25
  55. package/lib/checker/checks/aor.js +142 -2
  56. package/lib/checker/checks/api.js +142 -2
  57. package/lib/checker/checks/index.js +205 -25
  58. package/lib/checker/checks/wazo-websocket.js +2 -0
  59. package/lib/checker/checks/webrtc-transport.js +203 -25
  60. package/lib/checker/checks/webrtc.js +203 -25
  61. package/lib/domain/AdHocAPIConference.js +142 -2
  62. package/lib/domain/Features.js +142 -2
  63. package/lib/domain/Meeting.js +18 -0
  64. package/lib/domain/MeetingAuthorization.js +79 -0
  65. package/lib/domain/Phone/CTIPhone.js +142 -2
  66. package/lib/domain/Phone/WebRTCPhone.js +1 -3
  67. package/lib/domain/__tests__/Meeting.test.js +87 -1
  68. package/lib/domain/__tests__/MeetingAuthorization.test.js +111 -0
  69. package/lib/index.js +249 -31
  70. package/lib/lib/WazoSessionDescriptionHandler.js +22 -1
  71. package/lib/service/CallApi.js +142 -2
  72. package/lib/service/getApiClient.js +142 -2
  73. package/lib/simple/Auth.js +249 -31
  74. package/lib/simple/Configuration.js +249 -31
  75. package/lib/simple/Directory.js +142 -2
  76. package/lib/simple/Phone.js +249 -31
  77. package/lib/simple/Websocket.js +3 -0
  78. package/lib/simple/index.js +249 -31
  79. package/lib/simple/room/LocalParticipant.js +249 -31
  80. package/lib/simple/room/Participant.js +249 -31
  81. package/lib/simple/room/RemoteParticipant.js +249 -31
  82. package/lib/simple/room/Room.js +249 -31
  83. package/lib/simple/room/SipRoom.js +249 -31
  84. package/lib/simple/room/Stream.js +249 -31
  85. package/lib/simple/room/__tests__/Participant.test.js +14755 -0
  86. package/lib/simple/room/__tests__/RemoteParticipant.test.js +249 -31
  87. package/lib/simple/utils.js +249 -31
  88. package/lib/utils/__tests__/object.test.js +59 -0
  89. package/lib/utils/__tests__/sdp.test.js +50 -0
  90. package/lib/utils/__tests__/string.test.js +32 -0
  91. package/lib/utils/object.js +28 -0
  92. package/lib/utils/sdp.js +19 -0
  93. package/lib/utils/string.js +14 -0
  94. package/lib/web-rtc-client.js +203 -25
  95. package/lib/websocket-client.js +3 -0
  96. package/package.json +2 -2
  97. package/src/__tests__/web-rtc-client.test.js +46 -3
  98. package/src/api/calld.js +8 -0
  99. package/src/api/confd.js +43 -2
  100. package/src/domain/Meeting.js +20 -0
  101. package/src/domain/MeetingAuthorization.js +67 -0
  102. package/src/domain/Phone/WebRTCPhone.js +1 -3
  103. package/src/domain/__tests__/Meeting.test.js +70 -1
  104. package/src/domain/__tests__/MeetingAuthorization.test.js +58 -0
  105. package/src/lib/WazoSessionDescriptionHandler.js +5 -2
  106. package/src/simple/room/Participant.js +40 -0
  107. package/src/simple/room/Room.js +2 -2
  108. package/src/simple/room/SipRoom.js +1 -1
  109. package/src/simple/room/__tests__/Participant.test.js +81 -0
  110. package/src/types/WebSocketMessage.js +7 -1
  111. package/src/utils/__tests__/object.test.js +35 -0
  112. package/src/utils/__tests__/sdp.test.js +33 -1
  113. package/src/utils/__tests__/string.test.js +23 -0
  114. package/src/utils/object.js +15 -0
  115. package/src/utils/sdp.js +18 -0
  116. package/src/utils/string.js +8 -0
  117. package/src/web-rtc-client.js +39 -22
  118. package/src/websocket-client.js +2 -0
@@ -3171,6 +3171,70 @@ class ExternalApp {
3171
3171
 
3172
3172
  //
3173
3173
 
3174
+ class MeetingAuthorization {
3175
+
3176
+
3177
+
3178
+
3179
+
3180
+
3181
+ constructor({
3182
+ meetingUuid,
3183
+ uuid,
3184
+ userUuid,
3185
+ userName,
3186
+ } = {}) {
3187
+ this.meetingUuid = meetingUuid;
3188
+ this.uuid = uuid;
3189
+ this.userUuid = userUuid;
3190
+ this.userName = userName;
3191
+ }
3192
+
3193
+ setStatus(status ) {
3194
+ this.status = status;
3195
+ }
3196
+
3197
+ getStatus() {
3198
+ return this.status;
3199
+ }
3200
+
3201
+ static parse(plain ) {
3202
+ const {
3203
+ meeting_uuid: meetingUuid,
3204
+ uuid,
3205
+ guest_uuid: userUuid,
3206
+ guest_name: userName,
3207
+ } = plain;
3208
+
3209
+ return new MeetingAuthorization({
3210
+ meetingUuid,
3211
+ uuid,
3212
+ userUuid,
3213
+ userName,
3214
+ });
3215
+ }
3216
+
3217
+ static parseMany(items ) {
3218
+ if (!items) {
3219
+ return [];
3220
+ }
3221
+ return items.map(MeetingAuthorization.parse);
3222
+ }
3223
+ }
3224
+
3225
+ //
3226
+
3227
+
3228
+
3229
+
3230
+
3231
+
3232
+
3233
+
3234
+
3235
+
3236
+
3237
+
3174
3238
 
3175
3239
 
3176
3240
 
@@ -3181,6 +3245,7 @@ class ExternalApp {
3181
3245
 
3182
3246
 
3183
3247
 
3248
+
3184
3249
 
3185
3250
 
3186
3251
  class Meeting {
@@ -3195,6 +3260,8 @@ class Meeting {
3195
3260
 
3196
3261
 
3197
3262
 
3263
+
3264
+
3198
3265
 
3199
3266
  static parse(plain ) {
3200
3267
  return new Meeting({
@@ -3207,6 +3274,7 @@ class Meeting {
3207
3274
  extension: plain.exten,
3208
3275
  persistent: plain.persistent,
3209
3276
  creationTime: moment(plain.creation_time).toDate(),
3277
+ requireAuthorization: plain.require_authorization,
3210
3278
  });
3211
3279
  }
3212
3280
 
@@ -3231,6 +3299,7 @@ class Meeting {
3231
3299
  extension,
3232
3300
  persistent,
3233
3301
  creationTime,
3302
+ requireAuthorization,
3234
3303
  } = {}) {
3235
3304
  this.guestSipAuthorization = guestSipAuthorization;
3236
3305
  this.uri = uri;
@@ -3241,6 +3310,7 @@ class Meeting {
3241
3310
  this.extension = extension;
3242
3311
  this.persistent = persistent;
3243
3312
  this.creationTime = creationTime;
3313
+ this.requireAuthorization = requireAuthorization;
3244
3314
 
3245
3315
  // Useful to compare instead of instanceof with minified code
3246
3316
  this.type = 'Meeting';
@@ -3251,8 +3321,32 @@ class Meeting {
3251
3321
  const [username, secret] = atob(this.guestSipAuthorization).split(':');
3252
3322
  return { username, secret };
3253
3323
  }
3324
+
3254
3325
  }
3255
3326
 
3327
+ //
3328
+
3329
+ const camelToUnderscore = (key ) => {
3330
+ if (typeof key !== 'string') {
3331
+ throw new Error('Input is not a string');
3332
+ }
3333
+ return key.charAt(0).toLowerCase() + key.substring(1).replace(/([A-Z])/g, '_$1').toLowerCase();
3334
+ };
3335
+
3336
+ //
3337
+
3338
+ const convertKeysFromCamelToUnderscore = (args ) => {
3339
+ if (!args || typeof args !== 'object' || Array.isArray(args)) {
3340
+ throw new Error('Input is not an object');
3341
+ }
3342
+
3343
+ return Object.keys(args).reduce((acc, key) => {
3344
+ acc[camelToUnderscore(key)] = typeof args[key] === 'object' && !Array.isArray(args[key])
3345
+ ? convertKeysFromCamelToUnderscore(args[key]) : args[key];
3346
+ return acc;
3347
+ }, {});
3348
+ };
3349
+
3256
3350
  /* */
3257
3351
 
3258
3352
  var confdMethods = (client , baseUrl ) => ({
@@ -3321,8 +3415,18 @@ var confdMethods = (client , baseUrl ) => ({
3321
3415
  getMyMeetings: () =>
3322
3416
  client.get(`${baseUrl}/users/me/meetings`).then(response => Meeting.parseMany(response.items)),
3323
3417
 
3324
- createMyMeeting: (name , persistent ) =>
3325
- client.post(`${baseUrl}/users/me/meetings`, { name, persistent }).then(Meeting.parse),
3418
+ createMyMeeting: (args ) =>
3419
+ client
3420
+ .post(`${baseUrl}/users/me/meetings`, convertKeysFromCamelToUnderscore(args))
3421
+ .then(Meeting.parse),
3422
+
3423
+ updateMyMeeting: (meetingUuid , data ) =>
3424
+ client.put(
3425
+ `${baseUrl}/users/me/meetings/${meetingUuid}`,
3426
+ convertKeysFromCamelToUnderscore(data),
3427
+ null,
3428
+ ApiRequester.successResponseParser,
3429
+ ),
3326
3430
 
3327
3431
  deleteMyMeeting: (meetingUuid ) =>
3328
3432
  client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
@@ -3330,8 +3434,36 @@ var confdMethods = (client , baseUrl ) => ({
3330
3434
  getMeeting: (meetingUuid ) =>
3331
3435
  client.get(`${baseUrl}/meetings/${meetingUuid}`, null).then(Meeting.parse),
3332
3436
 
3437
+ meetingAuthorizations: (meetingUuid ) =>
3438
+ client.get(`${baseUrl}/users/me/meetings/${meetingUuid}/authorizations`, null).then(MeetingAuthorization.parseMany),
3439
+
3440
+ meetingAuthorizationReject: (meetingUuid , authorizationUuid ) =>
3441
+ client.put(
3442
+ `${baseUrl}/users/me/meetings/${meetingUuid}/authorizations/${authorizationUuid}/reject`,
3443
+ {},
3444
+ null,
3445
+ ApiRequester.successResponseParser,
3446
+ ),
3447
+
3448
+ meetingAuthorizationAccept: (meetingUuid , authorizationUuid ) =>
3449
+ client.put(
3450
+ `${baseUrl}/users/me/meetings/${meetingUuid}/authorizations/${authorizationUuid}/accept`,
3451
+ {},
3452
+ null,
3453
+ ApiRequester.successResponseParser,
3454
+ ),
3455
+
3333
3456
  guestGetMeeting: (meetingUuid ) =>
3334
3457
  client.get(`${baseUrl}/guests/me/meetings/${meetingUuid}`, null).then(Meeting.parse),
3458
+
3459
+ guestAuthorizationRequest: (userUuid , meetingUuid , username ) =>
3460
+ client
3461
+ .post(`${baseUrl}/guests/${userUuid}/meetings/${meetingUuid}/authorizations`, { guest_name: username })
3462
+ .then(MeetingAuthorization.parse),
3463
+
3464
+ guestAuthorizationCheck: (userUuid , meetingUuid , authorizationUuid ) =>
3465
+ client.get(`${baseUrl}/guests/${userUuid}/meetings/${meetingUuid}/authorizations/${authorizationUuid}`, null),
3466
+
3335
3467
  });
3336
3468
 
3337
3469
  //
@@ -4207,6 +4339,14 @@ var calldMethods = (client , baseUrl ) => ({
4207
4339
  getMeetingParticipantsAsUser: async (meetingUuid ) =>
4208
4340
  client.get(`${baseUrl}/users/me/meetings/${meetingUuid}/participants`),
4209
4341
 
4342
+ banMeetingParticipant: (meetingUuid , participantUuid ) =>
4343
+ client.delete(
4344
+ `${baseUrl}/users/me/meetings/${meetingUuid}/participants/${participantUuid}`,
4345
+ null,
4346
+ null,
4347
+ ApiRequester.successResponseParser,
4348
+ ),
4349
+
4210
4350
  listTrunks: () => client.get(`${baseUrl}/trunks`),
4211
4351
 
4212
4352
  mute: (callId ) =>
@@ -2625,6 +2625,70 @@ class ExternalApp {
2625
2625
 
2626
2626
  //
2627
2627
 
2628
+ class MeetingAuthorization {
2629
+
2630
+
2631
+
2632
+
2633
+
2634
+
2635
+ constructor({
2636
+ meetingUuid,
2637
+ uuid,
2638
+ userUuid,
2639
+ userName,
2640
+ } = {}) {
2641
+ this.meetingUuid = meetingUuid;
2642
+ this.uuid = uuid;
2643
+ this.userUuid = userUuid;
2644
+ this.userName = userName;
2645
+ }
2646
+
2647
+ setStatus(status ) {
2648
+ this.status = status;
2649
+ }
2650
+
2651
+ getStatus() {
2652
+ return this.status;
2653
+ }
2654
+
2655
+ static parse(plain ) {
2656
+ const {
2657
+ meeting_uuid: meetingUuid,
2658
+ uuid,
2659
+ guest_uuid: userUuid,
2660
+ guest_name: userName,
2661
+ } = plain;
2662
+
2663
+ return new MeetingAuthorization({
2664
+ meetingUuid,
2665
+ uuid,
2666
+ userUuid,
2667
+ userName,
2668
+ });
2669
+ }
2670
+
2671
+ static parseMany(items ) {
2672
+ if (!items) {
2673
+ return [];
2674
+ }
2675
+ return items.map(MeetingAuthorization.parse);
2676
+ }
2677
+ }
2678
+
2679
+ //
2680
+
2681
+
2682
+
2683
+
2684
+
2685
+
2686
+
2687
+
2688
+
2689
+
2690
+
2691
+
2628
2692
 
2629
2693
 
2630
2694
 
@@ -2635,6 +2699,7 @@ class ExternalApp {
2635
2699
 
2636
2700
 
2637
2701
 
2702
+
2638
2703
 
2639
2704
 
2640
2705
  class Meeting {
@@ -2649,6 +2714,8 @@ class Meeting {
2649
2714
 
2650
2715
 
2651
2716
 
2717
+
2718
+
2652
2719
 
2653
2720
  static parse(plain ) {
2654
2721
  return new Meeting({
@@ -2661,6 +2728,7 @@ class Meeting {
2661
2728
  extension: plain.exten,
2662
2729
  persistent: plain.persistent,
2663
2730
  creationTime: moment(plain.creation_time).toDate(),
2731
+ requireAuthorization: plain.require_authorization,
2664
2732
  });
2665
2733
  }
2666
2734
 
@@ -2685,6 +2753,7 @@ class Meeting {
2685
2753
  extension,
2686
2754
  persistent,
2687
2755
  creationTime,
2756
+ requireAuthorization,
2688
2757
  } = {}) {
2689
2758
  this.guestSipAuthorization = guestSipAuthorization;
2690
2759
  this.uri = uri;
@@ -2695,6 +2764,7 @@ class Meeting {
2695
2764
  this.extension = extension;
2696
2765
  this.persistent = persistent;
2697
2766
  this.creationTime = creationTime;
2767
+ this.requireAuthorization = requireAuthorization;
2698
2768
 
2699
2769
  // Useful to compare instead of instanceof with minified code
2700
2770
  this.type = 'Meeting';
@@ -2705,8 +2775,32 @@ class Meeting {
2705
2775
  const [username, secret] = atob(this.guestSipAuthorization).split(':');
2706
2776
  return { username, secret };
2707
2777
  }
2778
+
2708
2779
  }
2709
2780
 
2781
+ //
2782
+
2783
+ const camelToUnderscore = (key ) => {
2784
+ if (typeof key !== 'string') {
2785
+ throw new Error('Input is not a string');
2786
+ }
2787
+ return key.charAt(0).toLowerCase() + key.substring(1).replace(/([A-Z])/g, '_$1').toLowerCase();
2788
+ };
2789
+
2790
+ //
2791
+
2792
+ const convertKeysFromCamelToUnderscore = (args ) => {
2793
+ if (!args || typeof args !== 'object' || Array.isArray(args)) {
2794
+ throw new Error('Input is not an object');
2795
+ }
2796
+
2797
+ return Object.keys(args).reduce((acc, key) => {
2798
+ acc[camelToUnderscore(key)] = typeof args[key] === 'object' && !Array.isArray(args[key])
2799
+ ? convertKeysFromCamelToUnderscore(args[key]) : args[key];
2800
+ return acc;
2801
+ }, {});
2802
+ };
2803
+
2710
2804
  /* */
2711
2805
 
2712
2806
  var confdMethods = (client , baseUrl ) => ({
@@ -2775,8 +2869,18 @@ var confdMethods = (client , baseUrl ) => ({
2775
2869
  getMyMeetings: () =>
2776
2870
  client.get(`${baseUrl}/users/me/meetings`).then(response => Meeting.parseMany(response.items)),
2777
2871
 
2778
- createMyMeeting: (name , persistent ) =>
2779
- client.post(`${baseUrl}/users/me/meetings`, { name, persistent }).then(Meeting.parse),
2872
+ createMyMeeting: (args ) =>
2873
+ client
2874
+ .post(`${baseUrl}/users/me/meetings`, convertKeysFromCamelToUnderscore(args))
2875
+ .then(Meeting.parse),
2876
+
2877
+ updateMyMeeting: (meetingUuid , data ) =>
2878
+ client.put(
2879
+ `${baseUrl}/users/me/meetings/${meetingUuid}`,
2880
+ convertKeysFromCamelToUnderscore(data),
2881
+ null,
2882
+ ApiRequester.successResponseParser,
2883
+ ),
2780
2884
 
2781
2885
  deleteMyMeeting: (meetingUuid ) =>
2782
2886
  client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
@@ -2784,8 +2888,36 @@ var confdMethods = (client , baseUrl ) => ({
2784
2888
  getMeeting: (meetingUuid ) =>
2785
2889
  client.get(`${baseUrl}/meetings/${meetingUuid}`, null).then(Meeting.parse),
2786
2890
 
2891
+ meetingAuthorizations: (meetingUuid ) =>
2892
+ client.get(`${baseUrl}/users/me/meetings/${meetingUuid}/authorizations`, null).then(MeetingAuthorization.parseMany),
2893
+
2894
+ meetingAuthorizationReject: (meetingUuid , authorizationUuid ) =>
2895
+ client.put(
2896
+ `${baseUrl}/users/me/meetings/${meetingUuid}/authorizations/${authorizationUuid}/reject`,
2897
+ {},
2898
+ null,
2899
+ ApiRequester.successResponseParser,
2900
+ ),
2901
+
2902
+ meetingAuthorizationAccept: (meetingUuid , authorizationUuid ) =>
2903
+ client.put(
2904
+ `${baseUrl}/users/me/meetings/${meetingUuid}/authorizations/${authorizationUuid}/accept`,
2905
+ {},
2906
+ null,
2907
+ ApiRequester.successResponseParser,
2908
+ ),
2909
+
2787
2910
  guestGetMeeting: (meetingUuid ) =>
2788
2911
  client.get(`${baseUrl}/guests/me/meetings/${meetingUuid}`, null).then(Meeting.parse),
2912
+
2913
+ guestAuthorizationRequest: (userUuid , meetingUuid , username ) =>
2914
+ client
2915
+ .post(`${baseUrl}/guests/${userUuid}/meetings/${meetingUuid}/authorizations`, { guest_name: username })
2916
+ .then(MeetingAuthorization.parse),
2917
+
2918
+ guestAuthorizationCheck: (userUuid , meetingUuid , authorizationUuid ) =>
2919
+ client.get(`${baseUrl}/guests/${userUuid}/meetings/${meetingUuid}/authorizations/${authorizationUuid}`, null),
2920
+
2789
2921
  });
2790
2922
 
2791
2923
  //
@@ -4207,6 +4339,14 @@ var calldMethods = (client , baseUrl ) => ({
4207
4339
  getMeetingParticipantsAsUser: async (meetingUuid ) =>
4208
4340
  client.get(`${baseUrl}/users/me/meetings/${meetingUuid}/participants`),
4209
4341
 
4342
+ banMeetingParticipant: (meetingUuid , participantUuid ) =>
4343
+ client.delete(
4344
+ `${baseUrl}/users/me/meetings/${meetingUuid}/participants/${participantUuid}`,
4345
+ null,
4346
+ null,
4347
+ ApiRequester.successResponseParser,
4348
+ ),
4349
+
4210
4350
  listTrunks: () => client.get(`${baseUrl}/trunks`),
4211
4351
 
4212
4352
  mute: (callId ) =>