@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
@@ -25,6 +25,7 @@ const RECORD_STATE_ACTIVE = 'active';
25
25
 
26
26
 
27
27
 
28
+
28
29
 
29
30
 
30
31
 
@@ -35,6 +36,7 @@ const RECORD_STATE_ACTIVE = 'active';
35
36
 
36
37
 
37
38
 
39
+
38
40
 
39
41
 
40
42
 
@@ -63,6 +65,7 @@ class Call {
63
65
 
64
66
 
65
67
 
68
+
66
69
 
67
70
 
68
71
 
@@ -87,6 +90,7 @@ class Call {
87
90
  calleeNumber: plain.peer_caller_id_number,
88
91
  dialedExtension: plain.dialed_extension,
89
92
  isCaller: plain.is_caller,
93
+ isVideo: plain.is_video,
90
94
  muted: plain.muted,
91
95
  onHold: plain.on_hold,
92
96
  status: plain.status,
@@ -110,6 +114,7 @@ class Call {
110
114
  calleeNumber,
111
115
  dialedExtension,
112
116
  isCaller,
117
+ isVideo,
113
118
  lineId,
114
119
  muted,
115
120
  onHold,
@@ -133,6 +138,7 @@ class Call {
133
138
  this.startingTime = startingTime;
134
139
  this.talkingToIds = talkingToIds || [];
135
140
  this.recording = recording;
141
+ this.isVideo = !!isVideo;
136
142
 
137
143
  // Useful to compare instead of instanceof with minified code
138
144
  this.type = 'Call';
@@ -414,7 +414,7 @@ class CallSession {
414
414
  ringing: call.isRinging(),
415
415
  answered: call.isUp(),
416
416
  answeredBySystem: call.isUp() && call.talkingToIds.length === 0,
417
- cameraEnabled: false,
417
+ cameraEnabled: call.isVideo,
418
418
  dialedExtension: call.dialedExtension,
419
419
  call,
420
420
  conference: false, // @FIXME?
@@ -414,7 +414,7 @@ class CallSession {
414
414
  ringing: call.isRinging(),
415
415
  answered: call.isUp(),
416
416
  answeredBySystem: call.isUp() && call.talkingToIds.length === 0,
417
- cameraEnabled: false,
417
+ cameraEnabled: call.isVideo,
418
418
  dialedExtension: call.dialedExtension,
419
419
  call,
420
420
  conference: false, // @FIXME?
@@ -13,6 +13,17 @@ var newFrom = (instance , ToClass ) => {
13
13
 
14
14
  //
15
15
 
16
+
17
+
18
+
19
+
20
+
21
+
22
+
23
+
24
+
25
+
26
+
16
27
 
17
28
 
18
29
 
@@ -23,6 +34,7 @@ var newFrom = (instance , ToClass ) => {
23
34
 
24
35
 
25
36
 
37
+
26
38
 
27
39
 
28
40
  class Meeting {
@@ -37,6 +49,8 @@ class Meeting {
37
49
 
38
50
 
39
51
 
52
+
53
+
40
54
 
41
55
  static parse(plain ) {
42
56
  return new Meeting({
@@ -49,6 +63,7 @@ class Meeting {
49
63
  extension: plain.exten,
50
64
  persistent: plain.persistent,
51
65
  creationTime: moment(plain.creation_time).toDate(),
66
+ requireAuthorization: plain.require_authorization,
52
67
  });
53
68
  }
54
69
 
@@ -73,6 +88,7 @@ class Meeting {
73
88
  extension,
74
89
  persistent,
75
90
  creationTime,
91
+ requireAuthorization,
76
92
  } = {}) {
77
93
  this.guestSipAuthorization = guestSipAuthorization;
78
94
  this.uri = uri;
@@ -83,6 +99,7 @@ class Meeting {
83
99
  this.extension = extension;
84
100
  this.persistent = persistent;
85
101
  this.creationTime = creationTime;
102
+ this.requireAuthorization = requireAuthorization;
86
103
 
87
104
  // Useful to compare instead of instanceof with minified code
88
105
  this.type = 'Meeting';
@@ -93,11 +110,78 @@ class Meeting {
93
110
  const [username, secret] = atob(this.guestSipAuthorization).split(':');
94
111
  return { username, secret };
95
112
  }
113
+
96
114
  }
97
115
 
98
116
  //
99
117
 
118
+ const rawCreationTime = '2021-12-21T15:56:42.880Z';
119
+
100
120
  describe('Meeting domain', () => {
121
+ it('should retain its values when parsed', () => {
122
+ const args = {
123
+ guest_sip_authorization: 'some-guest-sip-authorization',
124
+ ingress_http_uri: 'some-uri',
125
+ name: 'some-name',
126
+ owner_uuids: ['some-owner-uuid'],
127
+ port: 'some-port',
128
+ uuid: 'some-uuid',
129
+ exten: 'some-exten',
130
+ persistent: true,
131
+ creation_time: rawCreationTime,
132
+ require_authorization: true,
133
+ };
134
+
135
+ const meeting = Meeting.parse(args);
136
+ const {
137
+ uri,
138
+ uuid,
139
+ name,
140
+ port,
141
+ extension,
142
+ persistent,
143
+ ownerUuids,
144
+ creationTime,
145
+ requireAuthorization,
146
+ } = meeting;
147
+
148
+ expect(uri).toEqual(args.ingress_http_uri);
149
+ expect(uuid).toEqual(args.uuid);
150
+ expect(name).toEqual(args.name);
151
+ expect(port).toEqual(args.port);
152
+ expect(extension).toEqual(args.exten);
153
+ expect(persistent).toEqual(args.persistent);
154
+ expect(ownerUuids).toEqual(args.owner_uuids);
155
+ expect(creationTime).toEqual(moment(rawCreationTime).toDate());
156
+ expect(requireAuthorization).toEqual(args.require_authorization);
157
+ });
158
+
159
+ it('should retain its values when instantiated', () => {
160
+ const keys = [
161
+ 'uuid',
162
+ 'name',
163
+ 'guestSipAuthorization',
164
+ 'ownerUuids',
165
+ 'port',
166
+ 'uri',
167
+ 'extension',
168
+ 'persistent',
169
+ 'creationTime',
170
+ 'requireAuthorization',
171
+ ];
172
+
173
+ const args = keys.reduce((acc, key) => {
174
+ acc[key] = `some-${key}`;
175
+ return acc;
176
+ }, {});
177
+
178
+ const meeting = new Meeting(args);
179
+
180
+ keys.forEach(key =>
181
+ // $FlowFixMe
182
+ expect(meeting[key]).toEqual(`some-${key}`));
183
+ });
184
+
101
185
  it('can return username and secret from an base64 encrypted string', () => {
102
186
  const USERNAME = 'username';
103
187
  const SECRET = 'secret';
@@ -112,6 +196,7 @@ describe('Meeting domain', () => {
112
196
  uuid: '',
113
197
  exten: '',
114
198
  persistent: false,
199
+ require_authorization: false,
115
200
  };
116
201
 
117
202
  const meeting = Meeting.parse(args);
@@ -124,7 +209,7 @@ describe('Meeting domain', () => {
124
209
 
125
210
  it('should return a date from a string', () => {
126
211
  const args = {
127
- creation_time: '2021-12-21T15:56:42.880Z',
212
+ creation_time: rawCreationTime,
128
213
  guest_sip_authorization: '',
129
214
  ingress_http_uri: '',
130
215
  name: '',
@@ -133,6 +218,7 @@ describe('Meeting domain', () => {
133
218
  uuid: '',
134
219
  exten: '',
135
220
  persistent: false,
221
+ require_authorization: false,
136
222
  };
137
223
 
138
224
  const { creationTime } = Meeting.parse(args);
@@ -0,0 +1,109 @@
1
+ //
2
+
3
+ class MeetingAuthorization {
4
+
5
+
6
+
7
+
8
+
9
+
10
+ constructor({
11
+ meetingUuid,
12
+ uuid,
13
+ userUuid,
14
+ userName,
15
+ } = {}) {
16
+ this.meetingUuid = meetingUuid;
17
+ this.uuid = uuid;
18
+ this.userUuid = userUuid;
19
+ this.userName = userName;
20
+ }
21
+
22
+ setStatus(status ) {
23
+ this.status = status;
24
+ }
25
+
26
+ getStatus() {
27
+ return this.status;
28
+ }
29
+
30
+ static parse(plain ) {
31
+ const {
32
+ meeting_uuid: meetingUuid,
33
+ uuid,
34
+ guest_uuid: userUuid,
35
+ guest_name: userName,
36
+ } = plain;
37
+
38
+ return new MeetingAuthorization({
39
+ meetingUuid,
40
+ uuid,
41
+ userUuid,
42
+ userName,
43
+ });
44
+ }
45
+
46
+ static parseMany(items ) {
47
+ if (!items) {
48
+ return [];
49
+ }
50
+ return items.map(MeetingAuthorization.parse);
51
+ }
52
+ }
53
+
54
+ describe('MeetingAuthorization', () => {
55
+ describe('parse', () => {
56
+ it('should parse a raw input', () => {
57
+ const rawAuthorization = {
58
+ created_at: 'today',
59
+ meeting_uuid: 'meeting_uuid',
60
+ uuid: 'uuid',
61
+ guest_uuid: 'guest_uuid',
62
+ guest_name: 'guest_name',
63
+ };
64
+
65
+ const authorization = {
66
+ meetingUuid: rawAuthorization.meeting_uuid,
67
+ uuid: rawAuthorization.uuid,
68
+ userUuid: rawAuthorization.guest_uuid,
69
+ userName: rawAuthorization.guest_name,
70
+ status: undefined,
71
+ };
72
+
73
+ const response = MeetingAuthorization.parse(rawAuthorization);
74
+ expect(response).toEqual(authorization);
75
+ });
76
+ });
77
+
78
+ describe('parseMany', () => {
79
+ it('should parse multiple raw inputs', () => {
80
+ const rawAuthorizations = [
81
+ {
82
+ created_at: 'today1',
83
+ meeting_uuid: 'meeting_uuid1',
84
+ uuid: 'uuid1',
85
+ guest_uuid: 'guest_uuid1',
86
+ guest_name: 'guest_name1',
87
+ },
88
+ {
89
+ created_at: 'today2',
90
+ meeting_uuid: 'meeting_uuid2',
91
+ uuid: 'uuid2',
92
+ guest_uuid: 'guest_uuid2',
93
+ guest_name: 'guest_name2',
94
+ },
95
+ ];
96
+
97
+ const authorizations = rawAuthorizations.map(rawAuthorization => ({
98
+ meetingUuid: rawAuthorization.meeting_uuid,
99
+ uuid: rawAuthorization.uuid,
100
+ userUuid: rawAuthorization.guest_uuid,
101
+ userName: rawAuthorization.guest_name,
102
+ status: undefined,
103
+ }));
104
+
105
+ const response = MeetingAuthorization.parseMany(rawAuthorizations);
106
+ expect(response).toEqual(authorizations);
107
+ });
108
+ });
109
+ });
@@ -414,7 +414,7 @@ class CallSession {
414
414
  ringing: call.isRinging(),
415
415
  answered: call.isUp(),
416
416
  answeredBySystem: call.isUp() && call.talkingToIds.length === 0,
417
- cameraEnabled: false,
417
+ cameraEnabled: call.isVideo,
418
418
  dialedExtension: call.dialedExtension,
419
419
  call,
420
420
  conference: false, // @FIXME?