@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
@@ -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
+ });