@wazo/sdk 0.37.20 → 0.37.24

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 (147) hide show
  1. package/dist/wazo-sdk.js +6 -6
  2. package/esm/__tests__/api-client.test.js +91 -21
  3. package/esm/__tests__/web-rtc-client.test.js +214 -165
  4. package/esm/api/agentd.js +25 -2
  5. package/esm/api/amid.js +26 -3
  6. package/esm/api/application.js +25 -2
  7. package/esm/api/auth.js +25 -2
  8. package/esm/api/call-logd.js +34 -4
  9. package/esm/api/calld.js +35 -2
  10. package/esm/api/chatd.js +32 -2
  11. package/esm/api/confd.js +56 -9
  12. package/esm/api/ctid-ng.js +38 -5
  13. package/esm/api/dird.js +29 -3
  14. package/esm/api/webhookd.js +26 -3
  15. package/esm/api-client.js +91 -21
  16. package/esm/checker/Checker.js +241 -190
  17. package/esm/checker/checks/aor.js +91 -21
  18. package/esm/checker/checks/api.js +91 -21
  19. package/esm/checker/checks/index.js +231 -180
  20. package/esm/checker/checks/wazo-websocket.js +42 -17
  21. package/esm/checker/checks/webrtc-transport.js +214 -165
  22. package/esm/checker/checks/webrtc.js +214 -165
  23. package/esm/domain/AdHocAPIConference.js +91 -21
  24. package/esm/domain/Call.js +3 -0
  25. package/esm/domain/CallLog.js +8 -1
  26. package/esm/domain/ChatMessage.js +4 -0
  27. package/esm/domain/ChatRoom.js +3 -0
  28. package/esm/domain/Contact.js +4 -1
  29. package/esm/domain/Features.js +91 -21
  30. package/esm/domain/Meeting.js +28 -5
  31. package/esm/domain/Phone/CTIPhone.js +109 -35
  32. package/esm/domain/Phone/WebRTCPhone.js +159 -102
  33. package/esm/domain/Recording.js +3 -0
  34. package/esm/domain/Voicemail.js +3 -0
  35. package/esm/domain/__tests__/Call.test.js +3 -0
  36. package/esm/domain/__tests__/CallLog.test.js +8 -1
  37. package/esm/domain/__tests__/Contact.test.js +4 -1
  38. package/esm/domain/__tests__/Meeting.test.js +144 -0
  39. package/esm/domain/__tests__/Voicemail.test.js +3 -0
  40. package/esm/index.js +509 -414
  41. package/esm/lib/WazoSessionDescriptionHandler.js +26 -41
  42. package/esm/service/CallApi.js +91 -21
  43. package/esm/service/IssueReporter.js +26 -3
  44. package/esm/service/__tests__/IssueReporter.test.js +26 -3
  45. package/esm/service/getApiClient.js +91 -21
  46. package/esm/simple/Auth.js +499 -404
  47. package/esm/simple/Configuration.js +499 -404
  48. package/esm/simple/Directory.js +91 -21
  49. package/esm/simple/Phone.js +499 -404
  50. package/esm/simple/Websocket.js +45 -19
  51. package/esm/simple/index.js +503 -408
  52. package/esm/simple/room/LocalParticipant.js +503 -408
  53. package/esm/simple/room/Participant.js +503 -408
  54. package/esm/simple/room/RemoteParticipant.js +503 -408
  55. package/esm/simple/room/Room.js +504 -409
  56. package/esm/simple/room/SipRoom.js +503 -408
  57. package/esm/simple/room/Stream.js +503 -408
  58. package/esm/simple/room/__tests__/RemoteParticipant.test.js +503 -408
  59. package/esm/simple/utils.js +503 -408
  60. package/esm/types/WebSocketMessage.js +1 -1
  61. package/esm/utils/__tests__/api-requester.test.js +25 -2
  62. package/esm/utils/api-requester.js +25 -2
  63. package/esm/web-rtc-client.js +214 -165
  64. package/esm/websocket-client.js +43 -18
  65. package/lib/__tests__/api-client.test.js +91 -21
  66. package/lib/__tests__/web-rtc-client.test.js +214 -165
  67. package/lib/api/agentd.js +25 -2
  68. package/lib/api/amid.js +26 -3
  69. package/lib/api/application.js +25 -2
  70. package/lib/api/auth.js +25 -2
  71. package/lib/api/call-logd.js +34 -4
  72. package/lib/api/calld.js +35 -2
  73. package/lib/api/chatd.js +32 -2
  74. package/lib/api/confd.js +56 -9
  75. package/lib/api/ctid-ng.js +38 -5
  76. package/lib/api/dird.js +29 -3
  77. package/lib/api/webhookd.js +26 -3
  78. package/lib/api-client.js +91 -21
  79. package/lib/checker/Checker.js +241 -190
  80. package/lib/checker/checks/aor.js +91 -21
  81. package/lib/checker/checks/api.js +91 -21
  82. package/lib/checker/checks/index.js +231 -180
  83. package/lib/checker/checks/wazo-websocket.js +42 -17
  84. package/lib/checker/checks/webrtc-transport.js +214 -165
  85. package/lib/checker/checks/webrtc.js +214 -165
  86. package/lib/domain/AdHocAPIConference.js +91 -21
  87. package/lib/domain/Call.js +3 -0
  88. package/lib/domain/CallLog.js +8 -1
  89. package/lib/domain/ChatMessage.js +4 -0
  90. package/lib/domain/ChatRoom.js +3 -0
  91. package/lib/domain/Contact.js +4 -1
  92. package/lib/domain/Features.js +91 -21
  93. package/lib/domain/Meeting.js +32 -5
  94. package/lib/domain/Phone/CTIPhone.js +109 -35
  95. package/lib/domain/Phone/WebRTCPhone.js +159 -102
  96. package/lib/domain/Recording.js +3 -0
  97. package/lib/domain/Voicemail.js +3 -0
  98. package/lib/domain/__tests__/Call.test.js +3 -0
  99. package/lib/domain/__tests__/CallLog.test.js +8 -1
  100. package/lib/domain/__tests__/Contact.test.js +4 -1
  101. package/lib/domain/__tests__/Meeting.test.js +150 -0
  102. package/lib/domain/__tests__/Voicemail.test.js +3 -0
  103. package/lib/index.js +509 -414
  104. package/lib/lib/WazoSessionDescriptionHandler.js +26 -41
  105. package/lib/service/CallApi.js +91 -21
  106. package/lib/service/IssueReporter.js +26 -3
  107. package/lib/service/__tests__/IssueReporter.test.js +26 -3
  108. package/lib/service/getApiClient.js +91 -21
  109. package/lib/simple/Auth.js +499 -404
  110. package/lib/simple/Configuration.js +499 -404
  111. package/lib/simple/Directory.js +91 -21
  112. package/lib/simple/Phone.js +499 -404
  113. package/lib/simple/Websocket.js +45 -19
  114. package/lib/simple/index.js +503 -408
  115. package/lib/simple/room/LocalParticipant.js +503 -408
  116. package/lib/simple/room/Participant.js +503 -408
  117. package/lib/simple/room/RemoteParticipant.js +503 -408
  118. package/lib/simple/room/Room.js +504 -409
  119. package/lib/simple/room/SipRoom.js +503 -408
  120. package/lib/simple/room/Stream.js +503 -408
  121. package/lib/simple/room/__tests__/RemoteParticipant.test.js +503 -408
  122. package/lib/simple/utils.js +503 -408
  123. package/lib/types/WebSocketMessage.js +2 -0
  124. package/lib/utils/__tests__/api-requester.test.js +25 -2
  125. package/lib/utils/api-requester.js +25 -2
  126. package/lib/web-rtc-client.js +214 -165
  127. package/lib/websocket-client.js +43 -17
  128. package/package.json +1 -1
  129. package/src/api/confd.js +5 -2
  130. package/src/domain/Call.js +3 -0
  131. package/src/domain/CallLog.js +4 -0
  132. package/src/domain/ChatMessage.js +4 -0
  133. package/src/domain/ChatRoom.js +3 -0
  134. package/src/domain/Contact.js +3 -0
  135. package/src/domain/Meeting.js +28 -5
  136. package/src/domain/Phone/CTIPhone.js +4 -0
  137. package/src/domain/Phone/Phone.js +2 -0
  138. package/src/domain/Phone/WebRTCPhone.js +49 -15
  139. package/src/domain/Recording.js +3 -0
  140. package/src/domain/Voicemail.js +3 -0
  141. package/src/domain/__tests__/Meeting.test.js +50 -0
  142. package/src/lib/WazoSessionDescriptionHandler.js +1 -35
  143. package/src/service/IssueReporter.js +25 -2
  144. package/src/simple/Phone.js +5 -0
  145. package/src/types/WebSocketMessage.js +5 -1
  146. package/src/web-rtc-client.js +41 -24
  147. package/src/websocket-client.js +2 -0
@@ -26,6 +26,9 @@ class Recording {
26
26
 
27
27
 
28
28
  static parseMany(recordings = []) {
29
+ if (!recordings) {
30
+ return [];
31
+ }
29
32
  return recordings.map(item => Recording.parse(item));
30
33
  }
31
34
 
@@ -71,6 +71,9 @@ class Voicemail {
71
71
  }
72
72
 
73
73
  static parseMany(plain ) {
74
+ if (!plain) {
75
+ return [];
76
+ }
74
77
  const plainUnread = plain.folders.filter(folder => folder.type === 'new')[0].messages;
75
78
  const plainRead = plain.folders.filter(folder => folder.type === 'old')[0].messages;
76
79
 
@@ -71,6 +71,9 @@ class Call {
71
71
 
72
72
 
73
73
  static parseMany(plain ) {
74
+ if (!plain) {
75
+ return [];
76
+ }
74
77
  return plain.map((plainCall ) => Call.parse(plainCall));
75
78
  }
76
79
 
@@ -26,7 +26,7 @@ BwIDAQAB
26
26
 
27
27
  //
28
28
 
29
- KEYUTIL.getKey(swarmPublicKey);
29
+ const swarmKey = KEYUTIL.getKey(swarmPublicKey);
30
30
 
31
31
  //
32
32
 
@@ -54,6 +54,9 @@ class Recording {
54
54
 
55
55
 
56
56
  static parseMany(recordings = []) {
57
+ if (!recordings) {
58
+ return [];
59
+ }
57
60
  return recordings.map(item => Recording.parse(item));
58
61
  }
59
62
 
@@ -155,6 +158,10 @@ class CallLog {
155
158
  }
156
159
 
157
160
  static parseMany(plain ) {
161
+ if (!plain || !plain.items) {
162
+ return [];
163
+ }
164
+
158
165
  return plain.items.map(item => CallLog.parse(item));
159
166
  }
160
167
 
@@ -44,7 +44,7 @@ const LINE_STATE = {
44
44
 
45
45
  //
46
46
 
47
- KEYUTIL.getKey(swarmPublicKey);
47
+ const swarmKey = KEYUTIL.getKey(swarmPublicKey);
48
48
 
49
49
  //
50
50
 
@@ -325,6 +325,9 @@ class Contact {
325
325
  }
326
326
 
327
327
  static parseMany(response ) {
328
+ if (!response || !response.results) {
329
+ return [];
330
+ }
328
331
  return response.results.map(r => Contact.parse(r, response.column_types));
329
332
  }
330
333
 
@@ -0,0 +1,144 @@
1
+ import moment from 'moment';
2
+
3
+ //
4
+
5
+ var newFrom = (instance , ToClass ) => {
6
+ const args = {};
7
+ Object.getOwnPropertyNames(instance).forEach(prop => {
8
+ args[prop] = instance[prop];
9
+ });
10
+
11
+ return new ToClass(args);
12
+ };
13
+
14
+ //
15
+
16
+
17
+
18
+
19
+
20
+
21
+
22
+
23
+
24
+
25
+
26
+
27
+
28
+ class Meeting {
29
+
30
+
31
+
32
+
33
+
34
+
35
+
36
+
37
+
38
+
39
+
40
+
41
+ static parse(plain ) {
42
+ return new Meeting({
43
+ guestSipAuthorization: plain.guest_sip_authorization,
44
+ uri: plain.ingress_http_uri,
45
+ name: plain.name,
46
+ ownerUuids: plain.owner_uuids,
47
+ port: plain.port,
48
+ uuid: plain.uuid,
49
+ extension: plain.exten,
50
+ persistent: plain.persistent,
51
+ creationTime: moment(plain.creation_time).toDate(),
52
+ });
53
+ }
54
+
55
+ static parseMany(items ) {
56
+ if (!items) {
57
+ return [];
58
+ }
59
+ return items.map(plain => Meeting.parse(plain));
60
+ }
61
+
62
+ static newFrom(meeting ) {
63
+ return newFrom(meeting, Meeting);
64
+ }
65
+
66
+ constructor({
67
+ uuid,
68
+ name,
69
+ guestSipAuthorization,
70
+ ownerUuids,
71
+ port,
72
+ uri,
73
+ extension,
74
+ persistent,
75
+ creationTime,
76
+ } = {}) {
77
+ this.guestSipAuthorization = guestSipAuthorization;
78
+ this.uri = uri;
79
+ this.name = name;
80
+ this.ownerUuids = ownerUuids;
81
+ this.port = port;
82
+ this.uuid = uuid;
83
+ this.extension = extension;
84
+ this.persistent = persistent;
85
+ this.creationTime = creationTime;
86
+
87
+ // Useful to compare instead of instanceof with minified code
88
+ this.type = 'Meeting';
89
+ }
90
+
91
+ getGuestSipCredentials() {
92
+ // eslint-disable-next-line no-undef
93
+ const [username, secret] = atob(this.guestSipAuthorization).split(':');
94
+ return { username, secret };
95
+ }
96
+ }
97
+
98
+ //
99
+
100
+ describe('Meeting domain', () => {
101
+ it('can return username and secret from an base64 encrypted string', () => {
102
+ const USERNAME = 'username';
103
+ const SECRET = 'secret';
104
+
105
+ const args = {
106
+ guest_sip_authorization: btoa(`${USERNAME}:${SECRET}`),
107
+ creation_time: '',
108
+ ingress_http_uri: '',
109
+ name: '',
110
+ owner_uuids: [],
111
+ port: '',
112
+ uuid: '',
113
+ exten: '',
114
+ persistent: false,
115
+ };
116
+
117
+ const meeting = Meeting.parse(args);
118
+
119
+ const { username, secret } = meeting.getGuestSipCredentials();
120
+
121
+ expect(username).toEqual(USERNAME);
122
+ expect(secret).toEqual(SECRET);
123
+ });
124
+
125
+ it('should return a date from a string', () => {
126
+ const args = {
127
+ creation_time: '2021-12-21T15:56:42.880Z',
128
+ guest_sip_authorization: '',
129
+ ingress_http_uri: '',
130
+ name: '',
131
+ owner_uuids: [],
132
+ port: '',
133
+ uuid: '',
134
+ exten: '',
135
+ persistent: false,
136
+ };
137
+
138
+ const { creationTime } = Meeting.parse(args);
139
+
140
+ expect(creationTime.getDate()).toEqual(21);
141
+ expect(creationTime.getFullYear()).toEqual(2021);
142
+ expect(creationTime.getMonth()).toEqual(11);
143
+ });
144
+ });
@@ -71,6 +71,9 @@ class Voicemail {
71
71
  }
72
72
 
73
73
  static parseMany(plain ) {
74
+ if (!plain) {
75
+ return [];
76
+ }
74
77
  const plainUnread = plain.folders.filter(folder => folder.type === 'new')[0].messages;
75
78
  const plainRead = plain.folders.filter(folder => folder.type === 'old')[0].messages;
76
79