@wazo/sdk 0.38.5 → 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 (135) hide show
  1. package/README.md +1 -1
  2. package/dist/wazo-sdk.js +2 -2
  3. package/esm/__tests__/api-client.test.js +148 -2
  4. package/esm/__tests__/web-rtc-client.test.js +303 -26
  5. package/esm/api/calld.js +14 -0
  6. package/esm/api/confd.js +134 -2
  7. package/esm/api/ctid-ng.js +6 -0
  8. package/esm/api-client.js +148 -2
  9. package/esm/checker/Checker.js +212 -26
  10. package/esm/checker/checks/aor.js +148 -2
  11. package/esm/checker/checks/api.js +148 -2
  12. package/esm/checker/checks/index.js +212 -26
  13. package/esm/checker/checks/wazo-websocket.js +2 -0
  14. package/esm/checker/checks/webrtc-transport.js +210 -26
  15. package/esm/checker/checks/webrtc.js +210 -26
  16. package/esm/domain/AdHocAPIConference.js +148 -2
  17. package/esm/domain/Call.js +6 -0
  18. package/esm/domain/CallSession.js +1 -1
  19. package/esm/domain/Features.js +148 -2
  20. package/esm/domain/Meeting.js +18 -0
  21. package/esm/domain/MeetingAuthorization.js +70 -0
  22. package/esm/domain/Phone/CTIPhone.js +149 -3
  23. package/esm/domain/Phone/WebRTCPhone.js +3 -3
  24. package/esm/domain/__tests__/Call.test.js +6 -0
  25. package/esm/domain/__tests__/CallSession.test.js +1 -1
  26. package/esm/domain/__tests__/IndirectTransfer.test.js +1 -1
  27. package/esm/domain/__tests__/Meeting.test.js +87 -1
  28. package/esm/domain/__tests__/MeetingAuthorization.test.js +109 -0
  29. package/esm/domain/__tests__/Room.test.js +1 -1
  30. package/esm/index.js +258 -32
  31. package/esm/lib/WazoSessionDescriptionHandler.js +22 -1
  32. package/esm/service/CallApi.js +148 -2
  33. package/esm/service/getApiClient.js +148 -2
  34. package/esm/simple/Auth.js +258 -32
  35. package/esm/simple/Configuration.js +258 -32
  36. package/esm/simple/Directory.js +148 -2
  37. package/esm/simple/Phone.js +258 -32
  38. package/esm/simple/Websocket.js +3 -0
  39. package/esm/simple/index.js +258 -32
  40. package/esm/simple/room/LocalParticipant.js +258 -32
  41. package/esm/simple/room/Participant.js +258 -32
  42. package/esm/simple/room/RemoteParticipant.js +258 -32
  43. package/esm/simple/room/Room.js +258 -32
  44. package/esm/simple/room/SipRoom.js +258 -32
  45. package/esm/simple/room/Stream.js +258 -32
  46. package/esm/simple/room/__tests__/Participant.test.js +14747 -0
  47. package/esm/simple/room/__tests__/RemoteParticipant.test.js +258 -32
  48. package/esm/simple/utils.js +258 -32
  49. package/esm/utils/__tests__/object.test.js +57 -0
  50. package/esm/utils/__tests__/sdp.test.js +50 -0
  51. package/esm/utils/__tests__/string.test.js +30 -0
  52. package/esm/utils/object.js +24 -0
  53. package/esm/utils/sdp.js +19 -1
  54. package/esm/utils/string.js +10 -0
  55. package/esm/web-rtc-client.js +210 -26
  56. package/esm/websocket-client.js +3 -1
  57. package/lib/__tests__/api-client.test.js +148 -2
  58. package/lib/__tests__/web-rtc-client.test.js +303 -26
  59. package/lib/api/calld.js +14 -0
  60. package/lib/api/confd.js +134 -2
  61. package/lib/api/ctid-ng.js +6 -0
  62. package/lib/api-client.js +148 -2
  63. package/lib/checker/Checker.js +212 -26
  64. package/lib/checker/checks/aor.js +148 -2
  65. package/lib/checker/checks/api.js +148 -2
  66. package/lib/checker/checks/index.js +212 -26
  67. package/lib/checker/checks/wazo-websocket.js +2 -0
  68. package/lib/checker/checks/webrtc-transport.js +210 -26
  69. package/lib/checker/checks/webrtc.js +210 -26
  70. package/lib/domain/AdHocAPIConference.js +148 -2
  71. package/lib/domain/Call.js +6 -0
  72. package/lib/domain/CallSession.js +1 -1
  73. package/lib/domain/Features.js +148 -2
  74. package/lib/domain/Meeting.js +18 -0
  75. package/lib/domain/MeetingAuthorization.js +79 -0
  76. package/lib/domain/Phone/CTIPhone.js +149 -3
  77. package/lib/domain/Phone/WebRTCPhone.js +3 -3
  78. package/lib/domain/__tests__/Call.test.js +6 -0
  79. package/lib/domain/__tests__/CallSession.test.js +1 -1
  80. package/lib/domain/__tests__/IndirectTransfer.test.js +1 -1
  81. package/lib/domain/__tests__/Meeting.test.js +87 -1
  82. package/lib/domain/__tests__/MeetingAuthorization.test.js +111 -0
  83. package/lib/domain/__tests__/Room.test.js +1 -1
  84. package/lib/index.js +258 -32
  85. package/lib/lib/WazoSessionDescriptionHandler.js +22 -1
  86. package/lib/service/CallApi.js +148 -2
  87. package/lib/service/getApiClient.js +148 -2
  88. package/lib/simple/Auth.js +258 -32
  89. package/lib/simple/Configuration.js +258 -32
  90. package/lib/simple/Directory.js +148 -2
  91. package/lib/simple/Phone.js +258 -32
  92. package/lib/simple/Websocket.js +3 -0
  93. package/lib/simple/index.js +258 -32
  94. package/lib/simple/room/LocalParticipant.js +258 -32
  95. package/lib/simple/room/Participant.js +258 -32
  96. package/lib/simple/room/RemoteParticipant.js +258 -32
  97. package/lib/simple/room/Room.js +258 -32
  98. package/lib/simple/room/SipRoom.js +258 -32
  99. package/lib/simple/room/Stream.js +258 -32
  100. package/lib/simple/room/__tests__/Participant.test.js +14757 -0
  101. package/lib/simple/room/__tests__/RemoteParticipant.test.js +258 -32
  102. package/lib/simple/utils.js +258 -32
  103. package/lib/utils/__tests__/object.test.js +59 -0
  104. package/lib/utils/__tests__/sdp.test.js +50 -0
  105. package/lib/utils/__tests__/string.test.js +32 -0
  106. package/lib/utils/object.js +28 -0
  107. package/lib/utils/sdp.js +19 -0
  108. package/lib/utils/string.js +14 -0
  109. package/lib/web-rtc-client.js +210 -26
  110. package/lib/websocket-client.js +3 -0
  111. package/package.json +2 -2
  112. package/src/__tests__/web-rtc-client.test.js +93 -0
  113. package/src/api/calld.js +8 -0
  114. package/src/api/confd.js +43 -2
  115. package/src/domain/Call.js +6 -0
  116. package/src/domain/CallSession.js +1 -1
  117. package/src/domain/Meeting.js +20 -0
  118. package/src/domain/MeetingAuthorization.js +67 -0
  119. package/src/domain/Phone/WebRTCPhone.js +2 -2
  120. package/src/domain/__tests__/Meeting.test.js +70 -1
  121. package/src/domain/__tests__/MeetingAuthorization.test.js +58 -0
  122. package/src/lib/WazoSessionDescriptionHandler.js +5 -2
  123. package/src/simple/room/Participant.js +40 -0
  124. package/src/simple/room/Room.js +2 -2
  125. package/src/simple/room/SipRoom.js +1 -1
  126. package/src/simple/room/__tests__/Participant.test.js +81 -0
  127. package/src/types/WebSocketMessage.js +7 -1
  128. package/src/utils/__tests__/object.test.js +35 -0
  129. package/src/utils/__tests__/sdp.test.js +33 -1
  130. package/src/utils/__tests__/string.test.js +23 -0
  131. package/src/utils/object.js +15 -0
  132. package/src/utils/sdp.js +18 -0
  133. package/src/utils/string.js +8 -0
  134. package/src/web-rtc-client.js +40 -23
  135. package/src/websocket-client.js +2 -0
@@ -31,6 +31,7 @@ const RECORD_STATE_ACTIVE = 'active';
31
31
 
32
32
 
33
33
 
34
+
34
35
 
35
36
 
36
37
 
@@ -41,6 +42,7 @@ const RECORD_STATE_ACTIVE = 'active';
41
42
 
42
43
 
43
44
 
45
+
44
46
 
45
47
 
46
48
 
@@ -69,6 +71,7 @@ class Call {
69
71
 
70
72
 
71
73
 
74
+
72
75
 
73
76
 
74
77
 
@@ -93,6 +96,7 @@ class Call {
93
96
  calleeNumber: plain.peer_caller_id_number,
94
97
  dialedExtension: plain.dialed_extension,
95
98
  isCaller: plain.is_caller,
99
+ isVideo: plain.is_video,
96
100
  muted: plain.muted,
97
101
  onHold: plain.on_hold,
98
102
  status: plain.status,
@@ -116,6 +120,7 @@ class Call {
116
120
  calleeNumber,
117
121
  dialedExtension,
118
122
  isCaller,
123
+ isVideo,
119
124
  lineId,
120
125
  muted,
121
126
  onHold,
@@ -139,6 +144,7 @@ class Call {
139
144
  this.startingTime = startingTime;
140
145
  this.talkingToIds = talkingToIds || [];
141
146
  this.recording = recording;
147
+ this.isVideo = !!isVideo;
142
148
 
143
149
  // Useful to compare instead of instanceof with minified code
144
150
  this.type = 'Call';
@@ -416,7 +416,7 @@ class CallSession {
416
416
  ringing: call.isRinging(),
417
417
  answered: call.isUp(),
418
418
  answeredBySystem: call.isUp() && call.talkingToIds.length === 0,
419
- cameraEnabled: false,
419
+ cameraEnabled: call.isVideo,
420
420
  dialedExtension: call.dialedExtension,
421
421
  call,
422
422
  conference: false, // @FIXME?
@@ -416,7 +416,7 @@ class CallSession {
416
416
  ringing: call.isRinging(),
417
417
  answered: call.isUp(),
418
418
  answeredBySystem: call.isUp() && call.talkingToIds.length === 0,
419
- cameraEnabled: false,
419
+ cameraEnabled: call.isVideo,
420
420
  dialedExtension: call.dialedExtension,
421
421
  call,
422
422
  conference: false, // @FIXME?
@@ -19,6 +19,17 @@ var newFrom = (instance , ToClass ) => {
19
19
 
20
20
  //
21
21
 
22
+
23
+
24
+
25
+
26
+
27
+
28
+
29
+
30
+
31
+
32
+
22
33
 
23
34
 
24
35
 
@@ -29,6 +40,7 @@ var newFrom = (instance , ToClass ) => {
29
40
 
30
41
 
31
42
 
43
+
32
44
 
33
45
 
34
46
  class Meeting {
@@ -43,6 +55,8 @@ class Meeting {
43
55
 
44
56
 
45
57
 
58
+
59
+
46
60
 
47
61
  static parse(plain ) {
48
62
  return new Meeting({
@@ -55,6 +69,7 @@ class Meeting {
55
69
  extension: plain.exten,
56
70
  persistent: plain.persistent,
57
71
  creationTime: moment__default['default'](plain.creation_time).toDate(),
72
+ requireAuthorization: plain.require_authorization,
58
73
  });
59
74
  }
60
75
 
@@ -79,6 +94,7 @@ class Meeting {
79
94
  extension,
80
95
  persistent,
81
96
  creationTime,
97
+ requireAuthorization,
82
98
  } = {}) {
83
99
  this.guestSipAuthorization = guestSipAuthorization;
84
100
  this.uri = uri;
@@ -89,6 +105,7 @@ class Meeting {
89
105
  this.extension = extension;
90
106
  this.persistent = persistent;
91
107
  this.creationTime = creationTime;
108
+ this.requireAuthorization = requireAuthorization;
92
109
 
93
110
  // Useful to compare instead of instanceof with minified code
94
111
  this.type = 'Meeting';
@@ -99,11 +116,78 @@ class Meeting {
99
116
  const [username, secret] = atob(this.guestSipAuthorization).split(':');
100
117
  return { username, secret };
101
118
  }
119
+
102
120
  }
103
121
 
104
122
  //
105
123
 
124
+ const rawCreationTime = '2021-12-21T15:56:42.880Z';
125
+
106
126
  describe('Meeting domain', () => {
127
+ it('should retain its values when parsed', () => {
128
+ const args = {
129
+ guest_sip_authorization: 'some-guest-sip-authorization',
130
+ ingress_http_uri: 'some-uri',
131
+ name: 'some-name',
132
+ owner_uuids: ['some-owner-uuid'],
133
+ port: 'some-port',
134
+ uuid: 'some-uuid',
135
+ exten: 'some-exten',
136
+ persistent: true,
137
+ creation_time: rawCreationTime,
138
+ require_authorization: true,
139
+ };
140
+
141
+ const meeting = Meeting.parse(args);
142
+ const {
143
+ uri,
144
+ uuid,
145
+ name,
146
+ port,
147
+ extension,
148
+ persistent,
149
+ ownerUuids,
150
+ creationTime,
151
+ requireAuthorization,
152
+ } = meeting;
153
+
154
+ expect(uri).toEqual(args.ingress_http_uri);
155
+ expect(uuid).toEqual(args.uuid);
156
+ expect(name).toEqual(args.name);
157
+ expect(port).toEqual(args.port);
158
+ expect(extension).toEqual(args.exten);
159
+ expect(persistent).toEqual(args.persistent);
160
+ expect(ownerUuids).toEqual(args.owner_uuids);
161
+ expect(creationTime).toEqual(moment__default['default'](rawCreationTime).toDate());
162
+ expect(requireAuthorization).toEqual(args.require_authorization);
163
+ });
164
+
165
+ it('should retain its values when instantiated', () => {
166
+ const keys = [
167
+ 'uuid',
168
+ 'name',
169
+ 'guestSipAuthorization',
170
+ 'ownerUuids',
171
+ 'port',
172
+ 'uri',
173
+ 'extension',
174
+ 'persistent',
175
+ 'creationTime',
176
+ 'requireAuthorization',
177
+ ];
178
+
179
+ const args = keys.reduce((acc, key) => {
180
+ acc[key] = `some-${key}`;
181
+ return acc;
182
+ }, {});
183
+
184
+ const meeting = new Meeting(args);
185
+
186
+ keys.forEach(key =>
187
+ // $FlowFixMe
188
+ expect(meeting[key]).toEqual(`some-${key}`));
189
+ });
190
+
107
191
  it('can return username and secret from an base64 encrypted string', () => {
108
192
  const USERNAME = 'username';
109
193
  const SECRET = 'secret';
@@ -118,6 +202,7 @@ describe('Meeting domain', () => {
118
202
  uuid: '',
119
203
  exten: '',
120
204
  persistent: false,
205
+ require_authorization: false,
121
206
  };
122
207
 
123
208
  const meeting = Meeting.parse(args);
@@ -130,7 +215,7 @@ describe('Meeting domain', () => {
130
215
 
131
216
  it('should return a date from a string', () => {
132
217
  const args = {
133
- creation_time: '2021-12-21T15:56:42.880Z',
218
+ creation_time: rawCreationTime,
134
219
  guest_sip_authorization: '',
135
220
  ingress_http_uri: '',
136
221
  name: '',
@@ -139,6 +224,7 @@ describe('Meeting domain', () => {
139
224
  uuid: '',
140
225
  exten: '',
141
226
  persistent: false,
227
+ require_authorization: false,
142
228
  };
143
229
 
144
230
  const { creationTime } = Meeting.parse(args);
@@ -0,0 +1,111 @@
1
+ 'use strict';
2
+
3
+ //
4
+
5
+ class MeetingAuthorization {
6
+
7
+
8
+
9
+
10
+
11
+
12
+ constructor({
13
+ meetingUuid,
14
+ uuid,
15
+ userUuid,
16
+ userName,
17
+ } = {}) {
18
+ this.meetingUuid = meetingUuid;
19
+ this.uuid = uuid;
20
+ this.userUuid = userUuid;
21
+ this.userName = userName;
22
+ }
23
+
24
+ setStatus(status ) {
25
+ this.status = status;
26
+ }
27
+
28
+ getStatus() {
29
+ return this.status;
30
+ }
31
+
32
+ static parse(plain ) {
33
+ const {
34
+ meeting_uuid: meetingUuid,
35
+ uuid,
36
+ guest_uuid: userUuid,
37
+ guest_name: userName,
38
+ } = plain;
39
+
40
+ return new MeetingAuthorization({
41
+ meetingUuid,
42
+ uuid,
43
+ userUuid,
44
+ userName,
45
+ });
46
+ }
47
+
48
+ static parseMany(items ) {
49
+ if (!items) {
50
+ return [];
51
+ }
52
+ return items.map(MeetingAuthorization.parse);
53
+ }
54
+ }
55
+
56
+ describe('MeetingAuthorization', () => {
57
+ describe('parse', () => {
58
+ it('should parse a raw input', () => {
59
+ const rawAuthorization = {
60
+ created_at: 'today',
61
+ meeting_uuid: 'meeting_uuid',
62
+ uuid: 'uuid',
63
+ guest_uuid: 'guest_uuid',
64
+ guest_name: 'guest_name',
65
+ };
66
+
67
+ const authorization = {
68
+ meetingUuid: rawAuthorization.meeting_uuid,
69
+ uuid: rawAuthorization.uuid,
70
+ userUuid: rawAuthorization.guest_uuid,
71
+ userName: rawAuthorization.guest_name,
72
+ status: undefined,
73
+ };
74
+
75
+ const response = MeetingAuthorization.parse(rawAuthorization);
76
+ expect(response).toEqual(authorization);
77
+ });
78
+ });
79
+
80
+ describe('parseMany', () => {
81
+ it('should parse multiple raw inputs', () => {
82
+ const rawAuthorizations = [
83
+ {
84
+ created_at: 'today1',
85
+ meeting_uuid: 'meeting_uuid1',
86
+ uuid: 'uuid1',
87
+ guest_uuid: 'guest_uuid1',
88
+ guest_name: 'guest_name1',
89
+ },
90
+ {
91
+ created_at: 'today2',
92
+ meeting_uuid: 'meeting_uuid2',
93
+ uuid: 'uuid2',
94
+ guest_uuid: 'guest_uuid2',
95
+ guest_name: 'guest_name2',
96
+ },
97
+ ];
98
+
99
+ const authorizations = rawAuthorizations.map(rawAuthorization => ({
100
+ meetingUuid: rawAuthorization.meeting_uuid,
101
+ uuid: rawAuthorization.uuid,
102
+ userUuid: rawAuthorization.guest_uuid,
103
+ userName: rawAuthorization.guest_name,
104
+ status: undefined,
105
+ }));
106
+
107
+ const response = MeetingAuthorization.parseMany(rawAuthorizations);
108
+ expect(response).toEqual(authorizations);
109
+ });
110
+ });
111
+ });
@@ -416,7 +416,7 @@ class CallSession {
416
416
  ringing: call.isRinging(),
417
417
  answered: call.isUp(),
418
418
  answeredBySystem: call.isUp() && call.talkingToIds.length === 0,
419
- cameraEnabled: false,
419
+ cameraEnabled: call.isVideo,
420
420
  dialedExtension: call.dialedExtension,
421
421
  call,
422
422
  conference: false, // @FIXME?