@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.
Files changed (121) hide show
  1. package/dist/wazo-sdk.js +2 -2
  2. package/esm/__tests__/api-client.test.js +163 -2
  3. package/esm/__tests__/web-rtc-client.test.js +248 -27
  4. package/esm/api/auth.js +12 -0
  5. package/esm/api/calld.js +8 -0
  6. package/esm/api/confd.js +134 -2
  7. package/esm/api/ctid-ng.js +1 -0
  8. package/esm/api-client.js +163 -2
  9. package/esm/checker/Checker.js +204 -24
  10. package/esm/checker/checks/aor.js +163 -2
  11. package/esm/checker/checks/api.js +163 -2
  12. package/esm/checker/checks/index.js +204 -24
  13. package/esm/checker/checks/wazo-websocket.js +2 -0
  14. package/esm/checker/checks/webrtc-transport.js +202 -24
  15. package/esm/checker/checks/webrtc.js +202 -24
  16. package/esm/domain/AdHocAPIConference.js +170 -4
  17. package/esm/domain/Features.js +170 -4
  18. package/esm/domain/Meeting.js +18 -0
  19. package/esm/domain/MeetingAuthorization.js +70 -0
  20. package/esm/domain/Phone/CTIPhone.js +170 -4
  21. package/esm/domain/Phone/WebRTCPhone.js +2 -3
  22. package/esm/domain/__tests__/Meeting.test.js +87 -1
  23. package/esm/domain/__tests__/MeetingAuthorization.test.js +109 -0
  24. package/esm/index.js +300 -36
  25. package/esm/service/CallApi.js +170 -4
  26. package/esm/service/getApiClient.js +176 -5
  27. package/esm/simple/Auth.js +301 -37
  28. package/esm/simple/Configuration.js +300 -36
  29. package/esm/simple/Directory.js +170 -4
  30. package/esm/simple/Phone.js +300 -36
  31. package/esm/simple/Softphone.js +5 -0
  32. package/esm/simple/Websocket.js +3 -0
  33. package/esm/simple/index.js +300 -36
  34. package/esm/simple/room/LocalParticipant.js +300 -36
  35. package/esm/simple/room/Participant.js +300 -36
  36. package/esm/simple/room/RemoteParticipant.js +300 -36
  37. package/esm/simple/room/Room.js +300 -36
  38. package/esm/simple/room/SipRoom.js +300 -36
  39. package/esm/simple/room/Stream.js +300 -36
  40. package/esm/simple/room/__tests__/Participant.test.js +14812 -0
  41. package/esm/simple/room/__tests__/RemoteParticipant.test.js +300 -36
  42. package/esm/simple/utils.js +300 -36
  43. package/esm/utils/__tests__/object.test.js +57 -0
  44. package/esm/utils/__tests__/string.test.js +30 -0
  45. package/esm/utils/object.js +24 -0
  46. package/esm/utils/string.js +10 -0
  47. package/esm/web-rtc-client.js +202 -24
  48. package/esm/websocket-client.js +3 -1
  49. package/lib/__tests__/api-client.test.js +163 -2
  50. package/lib/__tests__/web-rtc-client.test.js +248 -27
  51. package/lib/api/auth.js +12 -0
  52. package/lib/api/calld.js +8 -0
  53. package/lib/api/confd.js +134 -2
  54. package/lib/api/ctid-ng.js +1 -0
  55. package/lib/api-client.js +163 -2
  56. package/lib/checker/Checker.js +204 -24
  57. package/lib/checker/checks/aor.js +163 -2
  58. package/lib/checker/checks/api.js +163 -2
  59. package/lib/checker/checks/index.js +204 -24
  60. package/lib/checker/checks/wazo-websocket.js +2 -0
  61. package/lib/checker/checks/webrtc-transport.js +202 -24
  62. package/lib/checker/checks/webrtc.js +202 -24
  63. package/lib/domain/AdHocAPIConference.js +170 -4
  64. package/lib/domain/Features.js +170 -4
  65. package/lib/domain/Meeting.js +18 -0
  66. package/lib/domain/MeetingAuthorization.js +79 -0
  67. package/lib/domain/Phone/CTIPhone.js +170 -4
  68. package/lib/domain/Phone/WebRTCPhone.js +2 -3
  69. package/lib/domain/__tests__/Meeting.test.js +87 -1
  70. package/lib/domain/__tests__/MeetingAuthorization.test.js +111 -0
  71. package/lib/index.js +300 -36
  72. package/lib/service/CallApi.js +170 -4
  73. package/lib/service/getApiClient.js +176 -4
  74. package/lib/simple/Auth.js +301 -36
  75. package/lib/simple/Configuration.js +300 -36
  76. package/lib/simple/Directory.js +170 -4
  77. package/lib/simple/Phone.js +300 -36
  78. package/lib/simple/Softphone.js +5 -0
  79. package/lib/simple/Websocket.js +3 -0
  80. package/lib/simple/index.js +300 -36
  81. package/lib/simple/room/LocalParticipant.js +300 -36
  82. package/lib/simple/room/Participant.js +300 -36
  83. package/lib/simple/room/RemoteParticipant.js +300 -36
  84. package/lib/simple/room/Room.js +300 -36
  85. package/lib/simple/room/SipRoom.js +300 -36
  86. package/lib/simple/room/Stream.js +300 -36
  87. package/lib/simple/room/__tests__/Participant.test.js +14822 -0
  88. package/lib/simple/room/__tests__/RemoteParticipant.test.js +300 -36
  89. package/lib/simple/utils.js +300 -36
  90. package/lib/utils/__tests__/object.test.js +59 -0
  91. package/lib/utils/__tests__/string.test.js +32 -0
  92. package/lib/utils/object.js +28 -0
  93. package/lib/utils/string.js +14 -0
  94. package/lib/web-rtc-client.js +202 -24
  95. package/lib/websocket-client.js +3 -0
  96. package/package.json +1 -1
  97. package/src/__tests__/web-rtc-client.test.js +46 -3
  98. package/src/api/auth.js +12 -0
  99. package/src/api/calld.js +8 -0
  100. package/src/api/confd.js +43 -2
  101. package/src/api-client.js +8 -0
  102. package/src/domain/Meeting.js +20 -0
  103. package/src/domain/MeetingAuthorization.js +67 -0
  104. package/src/domain/Phone/WebRTCPhone.js +1 -3
  105. package/src/domain/__tests__/Meeting.test.js +70 -1
  106. package/src/domain/__tests__/MeetingAuthorization.test.js +58 -0
  107. package/src/service/getApiClient.js +13 -2
  108. package/src/simple/Auth.js +35 -4
  109. package/src/simple/Softphone.js +5 -0
  110. package/src/simple/index.js +2 -1
  111. package/src/simple/room/Participant.js +40 -0
  112. package/src/simple/room/Room.js +2 -2
  113. package/src/simple/room/SipRoom.js +1 -1
  114. package/src/simple/room/__tests__/Participant.test.js +81 -0
  115. package/src/types/WebSocketMessage.js +7 -1
  116. package/src/utils/__tests__/object.test.js +35 -0
  117. package/src/utils/__tests__/string.test.js +23 -0
  118. package/src/utils/object.js +15 -0
  119. package/src/utils/string.js +8 -0
  120. package/src/web-rtc-client.js +39 -22
  121. package/src/websocket-client.js +2 -0
@@ -0,0 +1,59 @@
1
+ 'use strict';
2
+
3
+ //
4
+
5
+ const camelToUnderscore = (key ) => {
6
+ if (typeof key !== 'string') {
7
+ throw new Error('Input is not a string');
8
+ }
9
+ return key.charAt(0).toLowerCase() + key.substring(1).replace(/([A-Z])/g, '_$1').toLowerCase();
10
+ };
11
+
12
+ //
13
+
14
+ const convertKeysFromCamelToUnderscore = (args ) => {
15
+ if (!args || typeof args !== 'object' || Array.isArray(args)) {
16
+ throw new Error('Input is not an object');
17
+ }
18
+
19
+ return Object.keys(args).reduce((acc, key) => {
20
+ acc[camelToUnderscore(key)] = typeof args[key] === 'object' && !Array.isArray(args[key])
21
+ ? convertKeysFromCamelToUnderscore(args[key]) : args[key];
22
+ return acc;
23
+ }, {});
24
+ };
25
+
26
+ //
27
+
28
+ describe('object utils', () => {
29
+ describe('convertKeysFromCamelToUnderscore', () => {
30
+ it('should throw an error when input is not an object', () => {
31
+ const msg = 'Input is not an object';
32
+ expect(() => convertKeysFromCamelToUnderscore(true)).toThrow(msg);
33
+ expect(() => convertKeysFromCamelToUnderscore(null)).toThrow(msg);
34
+ expect(() => convertKeysFromCamelToUnderscore(undefined)).toThrow(msg);
35
+ expect(() => convertKeysFromCamelToUnderscore([])).toThrow(msg);
36
+ expect(() => convertKeysFromCamelToUnderscore('some-string')).toThrow(msg);
37
+ });
38
+
39
+ it('should convert camel-cased keys to underscore', () => {
40
+ let value = Math.random();
41
+ expect(convertKeysFromCamelToUnderscore({ LoremIpsum: value })).toEqual({ lorem_ipsum: value });
42
+ value = Math.random();
43
+ expect(convertKeysFromCamelToUnderscore({ loremIpsum: value })).toEqual({ lorem_ipsum: value });
44
+ value = Math.random();
45
+ expect(convertKeysFromCamelToUnderscore({ 'lorem-ipsum': value })).toEqual({ 'lorem-ipsum': value });
46
+ value = Math.random();
47
+ expect(convertKeysFromCamelToUnderscore({ L123: value })).toEqual({ l123: value });
48
+ });
49
+
50
+ it('should handle multi-leveled object', () => {
51
+ const value = Math.random();
52
+ expect(convertKeysFromCamelToUnderscore({ LoremIpsum: { DoloreSit: { Amet: value }, regular: 'reg' } }))
53
+ .toEqual({ lorem_ipsum: { dolore_sit: { amet: value }, regular: 'reg' } });
54
+
55
+ expect(convertKeysFromCamelToUnderscore({ LoremIpsum: { DoloreSit: { Amet: [value] }, regular: ['something'] } }))
56
+ .toEqual({ lorem_ipsum: { dolore_sit: { amet: [value] }, regular: ['something'] } });
57
+ });
58
+ });
59
+ });
@@ -0,0 +1,32 @@
1
+ 'use strict';
2
+
3
+ //
4
+
5
+ const camelToUnderscore = (key ) => {
6
+ if (typeof key !== 'string') {
7
+ throw new Error('Input is not a string');
8
+ }
9
+ return key.charAt(0).toLowerCase() + key.substring(1).replace(/([A-Z])/g, '_$1').toLowerCase();
10
+ };
11
+
12
+ describe('string utils', () => {
13
+ describe('camelToUnderscore', () => {
14
+ it('', () => {
15
+ expect(() => camelToUnderscore(null)).toThrow('Input is not a string');
16
+ expect(() => camelToUnderscore(undefined)).toThrow('Input is not a string');
17
+ expect(() => camelToUnderscore({})).toThrow('Input is not a string');
18
+ expect(() => camelToUnderscore([])).toThrow('Input is not a string');
19
+ });
20
+
21
+ it('should convert camel-cased string to underscore', () => {
22
+ expect(camelToUnderscore('loremIpsum')).toEqual('lorem_ipsum');
23
+ expect(camelToUnderscore('lorem-ipsum')).toEqual('lorem-ipsum');
24
+ expect(camelToUnderscore('')).toEqual('');
25
+ });
26
+
27
+ it('should not prefix string with an underscore', () => {
28
+ expect(camelToUnderscore('LoremIpsum')).toEqual('lorem_ipsum');
29
+ expect(camelToUnderscore('L123')).toEqual('l123');
30
+ });
31
+ });
32
+ });
@@ -0,0 +1,28 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ //
6
+
7
+ const camelToUnderscore = (key ) => {
8
+ if (typeof key !== 'string') {
9
+ throw new Error('Input is not a string');
10
+ }
11
+ return key.charAt(0).toLowerCase() + key.substring(1).replace(/([A-Z])/g, '_$1').toLowerCase();
12
+ };
13
+
14
+ //
15
+
16
+ const convertKeysFromCamelToUnderscore = (args ) => {
17
+ if (!args || typeof args !== 'object' || Array.isArray(args)) {
18
+ throw new Error('Input is not an object');
19
+ }
20
+
21
+ return Object.keys(args).reduce((acc, key) => {
22
+ acc[camelToUnderscore(key)] = typeof args[key] === 'object' && !Array.isArray(args[key])
23
+ ? convertKeysFromCamelToUnderscore(args[key]) : args[key];
24
+ return acc;
25
+ }, {});
26
+ };
27
+
28
+ exports.convertKeysFromCamelToUnderscore = convertKeysFromCamelToUnderscore;
@@ -0,0 +1,14 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ //
6
+
7
+ const camelToUnderscore = (key ) => {
8
+ if (typeof key !== 'string') {
9
+ throw new Error('Input is not a string');
10
+ }
11
+ return key.charAt(0).toLowerCase() + key.substring(1).replace(/([A-Z])/g, '_$1').toLowerCase();
12
+ };
13
+
14
+ exports.camelToUnderscore = camelToUnderscore;
@@ -2797,6 +2797,7 @@ var authMethods = (client , baseUrl ) => ({
2797
2797
 
2798
2798
 
2799
2799
 
2800
+
2800
2801
  ) {
2801
2802
  const body = {
2802
2803
  backend: params.backend || DEFAULT_BACKEND_USER,
@@ -2817,9 +2818,14 @@ var authMethods = (client , baseUrl ) => ({
2817
2818
  }
2818
2819
 
2819
2820
  if (params.tenantId) {
2821
+ console.warn('Use of `tenantId` is deprecated when calling logIn() method, use `domainName` instead.');
2820
2822
  body.tenant_id = params.tenantId;
2821
2823
  }
2822
2824
 
2825
+ if (params.domainName) {
2826
+ body.domain_name = params.domainName;
2827
+ }
2828
+
2823
2829
  return client.post(`${baseUrl}/token`, body, headers).then(response => Session.parse(response));
2824
2830
  },
2825
2831
 
@@ -2832,6 +2838,7 @@ var authMethods = (client , baseUrl ) => ({
2832
2838
  expiration ,
2833
2839
  isMobile = false,
2834
2840
  tenantId ,
2841
+ domainName ,
2835
2842
  ) => {
2836
2843
  const body = {
2837
2844
  backend: backend || DEFAULT_BACKEND_USER,
@@ -2841,9 +2848,14 @@ var authMethods = (client , baseUrl ) => ({
2841
2848
  };
2842
2849
 
2843
2850
  if (tenantId) {
2851
+ console.warn('Use of `tenantId` is deprecated when calling refreshToken() method, use `domainName` instead.');
2844
2852
  body.tenant_id = tenantId;
2845
2853
  }
2846
2854
 
2855
+ if (domainName) {
2856
+ body.domain_name = domainName;
2857
+ }
2858
+
2847
2859
  const headers = {
2848
2860
  'Content-Type': 'application/json',
2849
2861
  ...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),
@@ -3213,6 +3225,70 @@ class ExternalApp {
3213
3225
 
3214
3226
  //
3215
3227
 
3228
+ class MeetingAuthorization {
3229
+
3230
+
3231
+
3232
+
3233
+
3234
+
3235
+ constructor({
3236
+ meetingUuid,
3237
+ uuid,
3238
+ userUuid,
3239
+ userName,
3240
+ } = {}) {
3241
+ this.meetingUuid = meetingUuid;
3242
+ this.uuid = uuid;
3243
+ this.userUuid = userUuid;
3244
+ this.userName = userName;
3245
+ }
3246
+
3247
+ setStatus(status ) {
3248
+ this.status = status;
3249
+ }
3250
+
3251
+ getStatus() {
3252
+ return this.status;
3253
+ }
3254
+
3255
+ static parse(plain ) {
3256
+ const {
3257
+ meeting_uuid: meetingUuid,
3258
+ uuid,
3259
+ guest_uuid: userUuid,
3260
+ guest_name: userName,
3261
+ } = plain;
3262
+
3263
+ return new MeetingAuthorization({
3264
+ meetingUuid,
3265
+ uuid,
3266
+ userUuid,
3267
+ userName,
3268
+ });
3269
+ }
3270
+
3271
+ static parseMany(items ) {
3272
+ if (!items) {
3273
+ return [];
3274
+ }
3275
+ return items.map(MeetingAuthorization.parse);
3276
+ }
3277
+ }
3278
+
3279
+ //
3280
+
3281
+
3282
+
3283
+
3284
+
3285
+
3286
+
3287
+
3288
+
3289
+
3290
+
3291
+
3216
3292
 
3217
3293
 
3218
3294
 
@@ -3223,6 +3299,7 @@ class ExternalApp {
3223
3299
 
3224
3300
 
3225
3301
 
3302
+
3226
3303
 
3227
3304
 
3228
3305
  class Meeting {
@@ -3237,6 +3314,8 @@ class Meeting {
3237
3314
 
3238
3315
 
3239
3316
 
3317
+
3318
+
3240
3319
 
3241
3320
  static parse(plain ) {
3242
3321
  return new Meeting({
@@ -3249,6 +3328,7 @@ class Meeting {
3249
3328
  extension: plain.exten,
3250
3329
  persistent: plain.persistent,
3251
3330
  creationTime: moment__default['default'](plain.creation_time).toDate(),
3331
+ requireAuthorization: plain.require_authorization,
3252
3332
  });
3253
3333
  }
3254
3334
 
@@ -3273,6 +3353,7 @@ class Meeting {
3273
3353
  extension,
3274
3354
  persistent,
3275
3355
  creationTime,
3356
+ requireAuthorization,
3276
3357
  } = {}) {
3277
3358
  this.guestSipAuthorization = guestSipAuthorization;
3278
3359
  this.uri = uri;
@@ -3283,6 +3364,7 @@ class Meeting {
3283
3364
  this.extension = extension;
3284
3365
  this.persistent = persistent;
3285
3366
  this.creationTime = creationTime;
3367
+ this.requireAuthorization = requireAuthorization;
3286
3368
 
3287
3369
  // Useful to compare instead of instanceof with minified code
3288
3370
  this.type = 'Meeting';
@@ -3293,8 +3375,32 @@ class Meeting {
3293
3375
  const [username, secret] = atob(this.guestSipAuthorization).split(':');
3294
3376
  return { username, secret };
3295
3377
  }
3378
+
3296
3379
  }
3297
3380
 
3381
+ //
3382
+
3383
+ const camelToUnderscore = (key ) => {
3384
+ if (typeof key !== 'string') {
3385
+ throw new Error('Input is not a string');
3386
+ }
3387
+ return key.charAt(0).toLowerCase() + key.substring(1).replace(/([A-Z])/g, '_$1').toLowerCase();
3388
+ };
3389
+
3390
+ //
3391
+
3392
+ const convertKeysFromCamelToUnderscore = (args ) => {
3393
+ if (!args || typeof args !== 'object' || Array.isArray(args)) {
3394
+ throw new Error('Input is not an object');
3395
+ }
3396
+
3397
+ return Object.keys(args).reduce((acc, key) => {
3398
+ acc[camelToUnderscore(key)] = typeof args[key] === 'object' && !Array.isArray(args[key])
3399
+ ? convertKeysFromCamelToUnderscore(args[key]) : args[key];
3400
+ return acc;
3401
+ }, {});
3402
+ };
3403
+
3298
3404
  /* */
3299
3405
 
3300
3406
  var confdMethods = (client , baseUrl ) => ({
@@ -3363,8 +3469,18 @@ var confdMethods = (client , baseUrl ) => ({
3363
3469
  getMyMeetings: () =>
3364
3470
  client.get(`${baseUrl}/users/me/meetings`).then(response => Meeting.parseMany(response.items)),
3365
3471
 
3366
- createMyMeeting: (name , persistent ) =>
3367
- client.post(`${baseUrl}/users/me/meetings`, { name, persistent }).then(Meeting.parse),
3472
+ createMyMeeting: (args ) =>
3473
+ client
3474
+ .post(`${baseUrl}/users/me/meetings`, convertKeysFromCamelToUnderscore(args))
3475
+ .then(Meeting.parse),
3476
+
3477
+ updateMyMeeting: (meetingUuid , data ) =>
3478
+ client.put(
3479
+ `${baseUrl}/users/me/meetings/${meetingUuid}`,
3480
+ convertKeysFromCamelToUnderscore(data),
3481
+ null,
3482
+ ApiRequester.successResponseParser,
3483
+ ),
3368
3484
 
3369
3485
  deleteMyMeeting: (meetingUuid ) =>
3370
3486
  client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
@@ -3372,8 +3488,36 @@ var confdMethods = (client , baseUrl ) => ({
3372
3488
  getMeeting: (meetingUuid ) =>
3373
3489
  client.get(`${baseUrl}/meetings/${meetingUuid}`, null).then(Meeting.parse),
3374
3490
 
3491
+ meetingAuthorizations: (meetingUuid ) =>
3492
+ client.get(`${baseUrl}/users/me/meetings/${meetingUuid}/authorizations`, null).then(MeetingAuthorization.parseMany),
3493
+
3494
+ meetingAuthorizationReject: (meetingUuid , authorizationUuid ) =>
3495
+ client.put(
3496
+ `${baseUrl}/users/me/meetings/${meetingUuid}/authorizations/${authorizationUuid}/reject`,
3497
+ {},
3498
+ null,
3499
+ ApiRequester.successResponseParser,
3500
+ ),
3501
+
3502
+ meetingAuthorizationAccept: (meetingUuid , authorizationUuid ) =>
3503
+ client.put(
3504
+ `${baseUrl}/users/me/meetings/${meetingUuid}/authorizations/${authorizationUuid}/accept`,
3505
+ {},
3506
+ null,
3507
+ ApiRequester.successResponseParser,
3508
+ ),
3509
+
3375
3510
  guestGetMeeting: (meetingUuid ) =>
3376
3511
  client.get(`${baseUrl}/guests/me/meetings/${meetingUuid}`, null).then(Meeting.parse),
3512
+
3513
+ guestAuthorizationRequest: (userUuid , meetingUuid , username ) =>
3514
+ client
3515
+ .post(`${baseUrl}/guests/${userUuid}/meetings/${meetingUuid}/authorizations`, { guest_name: username })
3516
+ .then(MeetingAuthorization.parse),
3517
+
3518
+ guestAuthorizationCheck: (userUuid , meetingUuid , authorizationUuid ) =>
3519
+ client.get(`${baseUrl}/guests/${userUuid}/meetings/${meetingUuid}/authorizations/${authorizationUuid}`, null),
3520
+
3377
3521
  });
3378
3522
 
3379
3523
  //
@@ -4138,6 +4282,7 @@ global.wazoClientId = global.wazoClientId || {};
4138
4282
  global.wazoClientToken = global.wazoClientToken || {};
4139
4283
  global.wazoRefreshToken = global.wazoRefreshToken || {};
4140
4284
  global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
4285
+ global.wazoRefreshDomainName = global.wazoRefreshDomainName || {};
4141
4286
  global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
4142
4287
  global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
4143
4288
  global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
@@ -4812,6 +4957,14 @@ var calldMethods = (client , baseUrl ) => ({
4812
4957
  getMeetingParticipantsAsUser: async (meetingUuid ) =>
4813
4958
  client.get(`${baseUrl}/users/me/meetings/${meetingUuid}/participants`),
4814
4959
 
4960
+ banMeetingParticipant: (meetingUuid , participantUuid ) =>
4961
+ client.delete(
4962
+ `${baseUrl}/users/me/meetings/${meetingUuid}/participants/${participantUuid}`,
4963
+ null,
4964
+ null,
4965
+ ApiRequester.successResponseParser,
4966
+ ),
4967
+
4815
4968
  listTrunks: () => client.get(`${baseUrl}/trunks`),
4816
4969
 
4817
4970
  mute: (callId ) =>
@@ -5189,6 +5342,7 @@ class ApiClient {
5189
5342
 
5190
5343
 
5191
5344
 
5345
+
5192
5346
 
5193
5347
 
5194
5348
 
@@ -5230,6 +5384,7 @@ class ApiClient {
5230
5384
  refreshToken: this.refreshToken,
5231
5385
  refreshBackend: this.refreshBackend,
5232
5386
  refreshTenantId: this.refreshTenantId,
5387
+ refreshDomainName: this.refreshDomainName,
5233
5388
  refreshExpiration: this.refreshExpiration,
5234
5389
  isMobile: this.isMobile,
5235
5390
  });
@@ -5245,6 +5400,7 @@ class ApiClient {
5245
5400
  this.refreshExpiration,
5246
5401
  this.isMobile,
5247
5402
  this.refreshTenantId,
5403
+ this.refreshDomainName,
5248
5404
  );
5249
5405
 
5250
5406
  logger$1.info('token refreshed', { token: session.token });
@@ -5298,9 +5454,14 @@ class ApiClient {
5298
5454
  }
5299
5455
 
5300
5456
  setRefreshTenantId(tenantId ) {
5457
+ console.warn('Use of `setRefreshTenantId` is deprecated, use `setRefreshDomainName` instead');
5301
5458
  this.refreshTenantId = tenantId;
5302
5459
  }
5303
5460
 
5461
+ setRefreshDomainName(domainName ) {
5462
+ this.refreshDomainName = domainName;
5463
+ }
5464
+
5304
5465
  setIsMobile(isMobile ) {
5305
5466
  this.isMobile = isMobile;
5306
5467
  }
@@ -6455,7 +6616,7 @@ class WebRTCClient extends Emitter {
6455
6616
  });
6456
6617
  }
6457
6618
 
6458
- changeAudioInputDevice(id , session , force ) {
6619
+ async changeAudioInputDevice(id , session , force ) {
6459
6620
  const currentId = this.getAudioDeviceId();
6460
6621
  logger.info('setting audio input device', { id, currentId, session: !!session });
6461
6622
 
@@ -6463,33 +6624,50 @@ class WebRTCClient extends Emitter {
6463
6624
  return null;
6464
6625
  }
6465
6626
 
6627
+ // in order to handle an audio track change for default devices
6628
+ // we need the actual id of the device (not 'default')
6629
+ let deviceId = id;
6630
+ if (id === 'default' && navigator.mediaDevices) {
6631
+ const devices = await navigator.mediaDevices.enumerateDevices();
6632
+ const defaultDevice = devices.find(device => device.deviceId === 'default');
6633
+ if (defaultDevice) {
6634
+ const deviceLabel = defaultDevice.label.replace('Default - ', '');
6635
+ const targetDevice = devices.find(device => device.label === deviceLabel);
6636
+ if (targetDevice) {
6637
+ deviceId = targetDevice.deviceId;
6638
+ if (!force && deviceId === currentId) {
6639
+ return null;
6640
+ }
6641
+ }
6642
+ }
6643
+ }
6644
+
6466
6645
  // let's update the local audio value
6467
6646
  if (this.audio) {
6468
6647
  this.audio = {
6469
6648
  deviceId: {
6470
- exact: id,
6649
+ exact: deviceId,
6471
6650
  },
6472
6651
  };
6473
6652
  }
6474
6653
 
6475
- if (session) {
6654
+ if (session && navigator.mediaDevices) {
6476
6655
  const sdh = session.sessionDescriptionHandler;
6477
6656
  const pc = sdh.peerConnection;
6478
6657
 
6479
- // $FlowFixMe
6480
- return navigator.mediaDevices.getUserMedia({ audio: { deviceId: { exact: id } } }).then(async stream => {
6481
- const audioTrack = stream.getAudioTracks()[0];
6482
- const sender = pc && pc.getSenders().find(s => audioTrack && s && s.track && s.track.kind === audioTrack.kind);
6658
+ const constraints = { audio: { deviceId: { exact: deviceId } } };
6659
+ const stream = await navigator.mediaDevices.getUserMedia(constraints);
6660
+ const audioTrack = stream.getAudioTracks()[0];
6661
+ const sender = pc && pc.getSenders().find(s => audioTrack && s && s.track && s.track.kind === audioTrack.kind);
6483
6662
 
6484
- if (sender) {
6485
- if (sender.track) {
6486
- audioTrack.enabled = sender.track.enabled;
6487
- }
6488
- sender.replaceTrack(audioTrack);
6663
+ if (sender) {
6664
+ if (sender.track) {
6665
+ audioTrack.enabled = sender.track.enabled;
6489
6666
  }
6667
+ sender.replaceTrack(audioTrack);
6668
+ }
6490
6669
 
6491
- return stream;
6492
- });
6670
+ return stream;
6493
6671
  }
6494
6672
  }
6495
6673
 
@@ -6509,14 +6687,14 @@ class WebRTCClient extends Emitter {
6509
6687
  return null;
6510
6688
  }
6511
6689
 
6512
- // let's update the local video value
6513
- if (this.video) {
6514
- this.video = {
6515
- deviceId: {
6516
- exact: id,
6517
- },
6518
- };
6519
- }
6690
+ // let's make sure we don't lose other video constraints settings -- width, height, frameRate...
6691
+ const videoObject = typeof this.video === 'object' ? this.video : {};
6692
+ this.video = {
6693
+ ...videoObject,
6694
+ deviceId: {
6695
+ exact: id,
6696
+ },
6697
+ };
6520
6698
  }
6521
6699
 
6522
6700
  changeSessionVideoInputDevice(id , session ) {
@@ -617,6 +617,7 @@ const AGENT_UNPAUSED = 'agent_unpaused';
617
617
  const CONFERENCE_ADHOC_PARTICIPANT_LEFT = 'conference_adhoc_participant_left';
618
618
  const CONFERENCE_ADHOC_DELETED = 'conference_adhoc_deleted';
619
619
  const MEETING_USER_PROGRESS = 'meeting_user_progress';
620
+ const MEETING_USER_GUEST_AUTHORIZATION_CREATED = 'meeting_user_guest_authorization_created';
620
621
 
621
622
  const BLACKLIST_EVENTS = [
622
623
  CHAT_MESSAGE_SENT,
@@ -968,6 +969,7 @@ WebSocketClient.eventLists = [
968
969
  CONFERENCE_ADHOC_PARTICIPANT_LEFT,
969
970
  CONFERENCE_ADHOC_DELETED,
970
971
  MEETING_USER_PROGRESS,
972
+ MEETING_USER_GUEST_AUTHORIZATION_CREATED,
971
973
  ];
972
974
 
973
975
  exports.AGENT_PAUSED = AGENT_PAUSED;
@@ -1021,6 +1023,7 @@ exports.FAX_OUTBOUND_USER_FAILED = FAX_OUTBOUND_USER_FAILED;
1021
1023
  exports.FAX_OUTBOUND_USER_SUCCEEDED = FAX_OUTBOUND_USER_SUCCEEDED;
1022
1024
  exports.HEARTBEAT_ENGINE_VERSION = HEARTBEAT_ENGINE_VERSION;
1023
1025
  exports.LINE_STATUS_UPDATED = LINE_STATUS_UPDATED;
1026
+ exports.MEETING_USER_GUEST_AUTHORIZATION_CREATED = MEETING_USER_GUEST_AUTHORIZATION_CREATED;
1024
1027
  exports.MEETING_USER_PARTICIPANT_JOINED = MEETING_USER_PARTICIPANT_JOINED;
1025
1028
  exports.MEETING_USER_PARTICIPANT_LEFT = MEETING_USER_PARTICIPANT_LEFT;
1026
1029
  exports.MEETING_USER_PROGRESS = MEETING_USER_PROGRESS;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wazo/sdk",
3
- "version": "0.38.7",
3
+ "version": "0.38.10",
4
4
  "description": "Wazo's JavaScript Software Development Kit.",
5
5
  "main": "dist/wazo-sdk.js",
6
6
  "author": "Wazo (http://wazo.io)",
@@ -69,27 +69,70 @@ describe('changeAudioInputDevice', () => {
69
69
  });
70
70
  });
71
71
 
72
+ const devices = [
73
+ { deviceId: 'default', kind: 'audioinput', label: 'Default - Fake Microphone', groupId: 'fak3Gr0up3' },
74
+ { deviceId: 'fak3d3v1c3', kind: 'audioinput', label: 'Fake Microphone', groupId: 'fak3Gr0up3' },
75
+ ];
76
+ const enumerateDevicesMock = jest.fn(async () => {
77
+ return new Promise(resolve => {
78
+ resolve(devices);
79
+ });
80
+ });
81
+
72
82
  Object.defineProperty(global.navigator, 'mediaDevices', {
73
83
  value: {
74
84
  getUserMedia: getUserMediaMock,
85
+ enumerateDevices: enumerateDevicesMock,
75
86
  },
76
87
  });
77
88
 
78
89
  it('should change the audio input track if the provided id is different', async () => {
79
90
  client.setMediaConstraints(constraints);
80
91
  expect(client.getAudioDeviceId()).toBe(defaultId);
81
- expect(client.changeAudioInputDevice(deviceId, session)).toBeTruthy();
92
+ const result = await client.changeAudioInputDevice(deviceId, session);
93
+ expect(result).toBeTruthy();
82
94
  });
83
95
 
84
96
  it('should NOT change the audio input track if the provided id is the same', async () => {
85
97
  client.setMediaConstraints(constraints);
86
98
  expect(client.getAudioDeviceId()).toBe(defaultId);
87
- expect(client.changeAudioInputDevice(defaultId, session)).toBeFalsy();
99
+ const result = await client.changeAudioInputDevice(defaultId, session);
100
+ expect(result).toBeFalsy();
88
101
  });
89
102
 
90
103
  it('should change the audio input track if the provided id is the same and force param is TRUE', async () => {
91
104
  client.setMediaConstraints(constraints);
92
105
  expect(client.getAudioDeviceId()).toBe(defaultId);
93
- expect(client.changeAudioInputDevice(defaultId, session, true)).toBeTruthy();
106
+ const result = await client.changeAudioInputDevice(defaultId, session, true);
107
+ expect(result).toBeTruthy();
108
+ });
109
+
110
+ describe('setVideoInputDevice', () => {
111
+ it('should retain its original video values', () => {
112
+ const video = { height: { min: 480, max: 720 }, width: { min: 640, max: 1280 } };
113
+
114
+ client.video = video;
115
+ client.setVideoInputDevice(deviceId);
116
+ expect(client.video).toEqual({ ...video, deviceId: { exact: deviceId } });
117
+ });
118
+
119
+ it('should set deviceId when video\'s original value is true', () => {
120
+ client.video = true;
121
+ client.setVideoInputDevice(deviceId);
122
+ expect(client.video).toEqual({ deviceId: { exact: deviceId } });
123
+ });
124
+
125
+ it('should set deviceId when video\'s original value is not set', () => {
126
+ client.video = undefined;
127
+ client.setVideoInputDevice(deviceId);
128
+ expect(client.video).toEqual({ deviceId: { exact: deviceId } });
129
+ });
130
+
131
+ it('should NOT set deviceId when its value does not change', () => {
132
+ client.video = { deviceId: { exact: deviceId } };
133
+ const result = client.setVideoInputDevice(deviceId);
134
+ expect(result).toEqual(null);
135
+ expect(client.video).toEqual({ deviceId: { exact: deviceId } });
136
+ });
94
137
  });
95
138
  });
package/src/api/auth.js CHANGED
@@ -33,6 +33,7 @@ export default (client: ApiRequester, baseUrl: string) => ({
33
33
  expiration: number,
34
34
  mobile?: boolean,
35
35
  tenantId?: string,
36
+ domainName?: string,
36
37
  }): Promise<?Session> {
37
38
  const body: Object = {
38
39
  backend: params.backend || DEFAULT_BACKEND_USER,
@@ -53,9 +54,14 @@ export default (client: ApiRequester, baseUrl: string) => ({
53
54
  }
54
55
 
55
56
  if (params.tenantId) {
57
+ console.warn('Use of `tenantId` is deprecated when calling logIn() method, use `domainName` instead.');
56
58
  body.tenant_id = params.tenantId;
57
59
  }
58
60
 
61
+ if (params.domainName) {
62
+ body.domain_name = params.domainName;
63
+ }
64
+
59
65
  return client.post(`${baseUrl}/token`, body, headers).then(response => Session.parse(response));
60
66
  },
61
67
 
@@ -68,6 +74,7 @@ export default (client: ApiRequester, baseUrl: string) => ({
68
74
  expiration: number,
69
75
  isMobile: boolean = false,
70
76
  tenantId: ?string,
77
+ domainName?: string,
71
78
  ): Promise<?Session> => {
72
79
  const body: Object = {
73
80
  backend: backend || DEFAULT_BACKEND_USER,
@@ -77,9 +84,14 @@ export default (client: ApiRequester, baseUrl: string) => ({
77
84
  };
78
85
 
79
86
  if (tenantId) {
87
+ console.warn('Use of `tenantId` is deprecated when calling refreshToken() method, use `domainName` instead.');
80
88
  body.tenant_id = tenantId;
81
89
  }
82
90
 
91
+ if (domainName) {
92
+ body.domain_name = domainName;
93
+ }
94
+
83
95
  const headers: Object = {
84
96
  'Content-Type': 'application/json',
85
97
  ...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),