@wazo/sdk 0.38.7 → 0.38.8

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 (106) 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 +227 -27
  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 +183 -24
  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 +183 -24
  11. package/esm/checker/checks/wazo-websocket.js +2 -0
  12. package/esm/checker/checks/webrtc-transport.js +181 -24
  13. package/esm/checker/checks/webrtc.js +181 -24
  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/__tests__/Meeting.test.js +87 -1
  20. package/esm/domain/__tests__/MeetingAuthorization.test.js +109 -0
  21. package/esm/index.js +226 -27
  22. package/esm/service/CallApi.js +142 -2
  23. package/esm/service/getApiClient.js +142 -2
  24. package/esm/simple/Auth.js +226 -27
  25. package/esm/simple/Configuration.js +226 -27
  26. package/esm/simple/Directory.js +142 -2
  27. package/esm/simple/Phone.js +226 -27
  28. package/esm/simple/Websocket.js +3 -0
  29. package/esm/simple/index.js +226 -27
  30. package/esm/simple/room/LocalParticipant.js +226 -27
  31. package/esm/simple/room/Participant.js +226 -27
  32. package/esm/simple/room/RemoteParticipant.js +226 -27
  33. package/esm/simple/room/Room.js +226 -27
  34. package/esm/simple/room/SipRoom.js +226 -27
  35. package/esm/simple/room/Stream.js +226 -27
  36. package/esm/simple/room/__tests__/Participant.test.js +14747 -0
  37. package/esm/simple/room/__tests__/RemoteParticipant.test.js +226 -27
  38. package/esm/simple/utils.js +226 -27
  39. package/esm/utils/__tests__/object.test.js +57 -0
  40. package/esm/utils/__tests__/string.test.js +30 -0
  41. package/esm/utils/object.js +24 -0
  42. package/esm/utils/string.js +10 -0
  43. package/esm/web-rtc-client.js +181 -24
  44. package/esm/websocket-client.js +3 -1
  45. package/lib/__tests__/api-client.test.js +142 -2
  46. package/lib/__tests__/web-rtc-client.test.js +227 -27
  47. package/lib/api/calld.js +8 -0
  48. package/lib/api/confd.js +134 -2
  49. package/lib/api-client.js +142 -2
  50. package/lib/checker/Checker.js +183 -24
  51. package/lib/checker/checks/aor.js +142 -2
  52. package/lib/checker/checks/api.js +142 -2
  53. package/lib/checker/checks/index.js +183 -24
  54. package/lib/checker/checks/wazo-websocket.js +2 -0
  55. package/lib/checker/checks/webrtc-transport.js +181 -24
  56. package/lib/checker/checks/webrtc.js +181 -24
  57. package/lib/domain/AdHocAPIConference.js +142 -2
  58. package/lib/domain/Features.js +142 -2
  59. package/lib/domain/Meeting.js +18 -0
  60. package/lib/domain/MeetingAuthorization.js +79 -0
  61. package/lib/domain/Phone/CTIPhone.js +142 -2
  62. package/lib/domain/__tests__/Meeting.test.js +87 -1
  63. package/lib/domain/__tests__/MeetingAuthorization.test.js +111 -0
  64. package/lib/index.js +226 -27
  65. package/lib/service/CallApi.js +142 -2
  66. package/lib/service/getApiClient.js +142 -2
  67. package/lib/simple/Auth.js +226 -27
  68. package/lib/simple/Configuration.js +226 -27
  69. package/lib/simple/Directory.js +142 -2
  70. package/lib/simple/Phone.js +226 -27
  71. package/lib/simple/Websocket.js +3 -0
  72. package/lib/simple/index.js +226 -27
  73. package/lib/simple/room/LocalParticipant.js +226 -27
  74. package/lib/simple/room/Participant.js +226 -27
  75. package/lib/simple/room/RemoteParticipant.js +226 -27
  76. package/lib/simple/room/Room.js +226 -27
  77. package/lib/simple/room/SipRoom.js +226 -27
  78. package/lib/simple/room/Stream.js +226 -27
  79. package/lib/simple/room/__tests__/Participant.test.js +14757 -0
  80. package/lib/simple/room/__tests__/RemoteParticipant.test.js +226 -27
  81. package/lib/simple/utils.js +226 -27
  82. package/lib/utils/__tests__/object.test.js +59 -0
  83. package/lib/utils/__tests__/string.test.js +32 -0
  84. package/lib/utils/object.js +28 -0
  85. package/lib/utils/string.js +14 -0
  86. package/lib/web-rtc-client.js +181 -24
  87. package/lib/websocket-client.js +3 -0
  88. package/package.json +2 -2
  89. package/src/__tests__/web-rtc-client.test.js +46 -3
  90. package/src/api/calld.js +8 -0
  91. package/src/api/confd.js +43 -2
  92. package/src/domain/Meeting.js +20 -0
  93. package/src/domain/MeetingAuthorization.js +67 -0
  94. package/src/domain/__tests__/Meeting.test.js +70 -1
  95. package/src/domain/__tests__/MeetingAuthorization.test.js +58 -0
  96. package/src/simple/room/Participant.js +40 -0
  97. package/src/simple/room/Room.js +2 -2
  98. package/src/simple/room/SipRoom.js +1 -1
  99. package/src/simple/room/__tests__/Participant.test.js +81 -0
  100. package/src/types/WebSocketMessage.js +7 -1
  101. package/src/utils/__tests__/object.test.js +35 -0
  102. package/src/utils/__tests__/string.test.js +23 -0
  103. package/src/utils/object.js +15 -0
  104. package/src/utils/string.js +8 -0
  105. package/src/web-rtc-client.js +39 -22
  106. package/src/websocket-client.js +2 -0
package/esm/api/confd.js CHANGED
@@ -1286,6 +1286,70 @@ class ExternalApp {
1286
1286
 
1287
1287
  //
1288
1288
 
1289
+ class MeetingAuthorization {
1290
+
1291
+
1292
+
1293
+
1294
+
1295
+
1296
+ constructor({
1297
+ meetingUuid,
1298
+ uuid,
1299
+ userUuid,
1300
+ userName,
1301
+ } = {}) {
1302
+ this.meetingUuid = meetingUuid;
1303
+ this.uuid = uuid;
1304
+ this.userUuid = userUuid;
1305
+ this.userName = userName;
1306
+ }
1307
+
1308
+ setStatus(status ) {
1309
+ this.status = status;
1310
+ }
1311
+
1312
+ getStatus() {
1313
+ return this.status;
1314
+ }
1315
+
1316
+ static parse(plain ) {
1317
+ const {
1318
+ meeting_uuid: meetingUuid,
1319
+ uuid,
1320
+ guest_uuid: userUuid,
1321
+ guest_name: userName,
1322
+ } = plain;
1323
+
1324
+ return new MeetingAuthorization({
1325
+ meetingUuid,
1326
+ uuid,
1327
+ userUuid,
1328
+ userName,
1329
+ });
1330
+ }
1331
+
1332
+ static parseMany(items ) {
1333
+ if (!items) {
1334
+ return [];
1335
+ }
1336
+ return items.map(MeetingAuthorization.parse);
1337
+ }
1338
+ }
1339
+
1340
+ //
1341
+
1342
+
1343
+
1344
+
1345
+
1346
+
1347
+
1348
+
1349
+
1350
+
1351
+
1352
+
1289
1353
 
1290
1354
 
1291
1355
 
@@ -1296,6 +1360,7 @@ class ExternalApp {
1296
1360
 
1297
1361
 
1298
1362
 
1363
+
1299
1364
 
1300
1365
 
1301
1366
  class Meeting {
@@ -1310,6 +1375,8 @@ class Meeting {
1310
1375
 
1311
1376
 
1312
1377
 
1378
+
1379
+
1313
1380
 
1314
1381
  static parse(plain ) {
1315
1382
  return new Meeting({
@@ -1322,6 +1389,7 @@ class Meeting {
1322
1389
  extension: plain.exten,
1323
1390
  persistent: plain.persistent,
1324
1391
  creationTime: moment(plain.creation_time).toDate(),
1392
+ requireAuthorization: plain.require_authorization,
1325
1393
  });
1326
1394
  }
1327
1395
 
@@ -1346,6 +1414,7 @@ class Meeting {
1346
1414
  extension,
1347
1415
  persistent,
1348
1416
  creationTime,
1417
+ requireAuthorization,
1349
1418
  } = {}) {
1350
1419
  this.guestSipAuthorization = guestSipAuthorization;
1351
1420
  this.uri = uri;
@@ -1356,6 +1425,7 @@ class Meeting {
1356
1425
  this.extension = extension;
1357
1426
  this.persistent = persistent;
1358
1427
  this.creationTime = creationTime;
1428
+ this.requireAuthorization = requireAuthorization;
1359
1429
 
1360
1430
  // Useful to compare instead of instanceof with minified code
1361
1431
  this.type = 'Meeting';
@@ -1366,8 +1436,32 @@ class Meeting {
1366
1436
  const [username, secret] = atob(this.guestSipAuthorization).split(':');
1367
1437
  return { username, secret };
1368
1438
  }
1439
+
1369
1440
  }
1370
1441
 
1442
+ //
1443
+
1444
+ const camelToUnderscore = (key ) => {
1445
+ if (typeof key !== 'string') {
1446
+ throw new Error('Input is not a string');
1447
+ }
1448
+ return key.charAt(0).toLowerCase() + key.substring(1).replace(/([A-Z])/g, '_$1').toLowerCase();
1449
+ };
1450
+
1451
+ //
1452
+
1453
+ const convertKeysFromCamelToUnderscore = (args ) => {
1454
+ if (!args || typeof args !== 'object' || Array.isArray(args)) {
1455
+ throw new Error('Input is not an object');
1456
+ }
1457
+
1458
+ return Object.keys(args).reduce((acc, key) => {
1459
+ acc[camelToUnderscore(key)] = typeof args[key] === 'object' && !Array.isArray(args[key])
1460
+ ? convertKeysFromCamelToUnderscore(args[key]) : args[key];
1461
+ return acc;
1462
+ }, {});
1463
+ };
1464
+
1371
1465
  /* */
1372
1466
 
1373
1467
  var confd = (client , baseUrl ) => ({
@@ -1436,8 +1530,18 @@ var confd = (client , baseUrl ) => ({
1436
1530
  getMyMeetings: () =>
1437
1531
  client.get(`${baseUrl}/users/me/meetings`).then(response => Meeting.parseMany(response.items)),
1438
1532
 
1439
- createMyMeeting: (name , persistent ) =>
1440
- client.post(`${baseUrl}/users/me/meetings`, { name, persistent }).then(Meeting.parse),
1533
+ createMyMeeting: (args ) =>
1534
+ client
1535
+ .post(`${baseUrl}/users/me/meetings`, convertKeysFromCamelToUnderscore(args))
1536
+ .then(Meeting.parse),
1537
+
1538
+ updateMyMeeting: (meetingUuid , data ) =>
1539
+ client.put(
1540
+ `${baseUrl}/users/me/meetings/${meetingUuid}`,
1541
+ convertKeysFromCamelToUnderscore(data),
1542
+ null,
1543
+ ApiRequester.successResponseParser,
1544
+ ),
1441
1545
 
1442
1546
  deleteMyMeeting: (meetingUuid ) =>
1443
1547
  client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
@@ -1445,8 +1549,36 @@ var confd = (client , baseUrl ) => ({
1445
1549
  getMeeting: (meetingUuid ) =>
1446
1550
  client.get(`${baseUrl}/meetings/${meetingUuid}`, null).then(Meeting.parse),
1447
1551
 
1552
+ meetingAuthorizations: (meetingUuid ) =>
1553
+ client.get(`${baseUrl}/users/me/meetings/${meetingUuid}/authorizations`, null).then(MeetingAuthorization.parseMany),
1554
+
1555
+ meetingAuthorizationReject: (meetingUuid , authorizationUuid ) =>
1556
+ client.put(
1557
+ `${baseUrl}/users/me/meetings/${meetingUuid}/authorizations/${authorizationUuid}/reject`,
1558
+ {},
1559
+ null,
1560
+ ApiRequester.successResponseParser,
1561
+ ),
1562
+
1563
+ meetingAuthorizationAccept: (meetingUuid , authorizationUuid ) =>
1564
+ client.put(
1565
+ `${baseUrl}/users/me/meetings/${meetingUuid}/authorizations/${authorizationUuid}/accept`,
1566
+ {},
1567
+ null,
1568
+ ApiRequester.successResponseParser,
1569
+ ),
1570
+
1448
1571
  guestGetMeeting: (meetingUuid ) =>
1449
1572
  client.get(`${baseUrl}/guests/me/meetings/${meetingUuid}`, null).then(Meeting.parse),
1573
+
1574
+ guestAuthorizationRequest: (userUuid , meetingUuid , username ) =>
1575
+ client
1576
+ .post(`${baseUrl}/guests/${userUuid}/meetings/${meetingUuid}/authorizations`, { guest_name: username })
1577
+ .then(MeetingAuthorization.parse),
1578
+
1579
+ guestAuthorizationCheck: (userUuid , meetingUuid , authorizationUuid ) =>
1580
+ client.get(`${baseUrl}/guests/${userUuid}/meetings/${meetingUuid}/authorizations/${authorizationUuid}`, null),
1581
+
1450
1582
  });
1451
1583
 
1452
1584
  export default confd;
package/esm/api-client.js CHANGED
@@ -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
  //
@@ -4224,6 +4356,14 @@ var calldMethods = (client , baseUrl ) => ({
4224
4356
  getMeetingParticipantsAsUser: async (meetingUuid ) =>
4225
4357
  client.get(`${baseUrl}/users/me/meetings/${meetingUuid}/participants`),
4226
4358
 
4359
+ banMeetingParticipant: (meetingUuid , participantUuid ) =>
4360
+ client.delete(
4361
+ `${baseUrl}/users/me/meetings/${meetingUuid}/participants/${participantUuid}`,
4362
+ null,
4363
+ null,
4364
+ ApiRequester.successResponseParser,
4365
+ ),
4366
+
4227
4367
  listTrunks: () => client.get(`${baseUrl}/trunks`),
4228
4368
 
4229
4369
  mute: (callId ) =>