@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
@@ -32,6 +32,9 @@ class Recording {
32
32
 
33
33
 
34
34
  static parseMany(recordings = []) {
35
+ if (!recordings) {
36
+ return [];
37
+ }
35
38
  return recordings.map(item => Recording.parse(item));
36
39
  }
37
40
 
@@ -77,6 +77,9 @@ class Voicemail {
77
77
  }
78
78
 
79
79
  static parseMany(plain ) {
80
+ if (!plain) {
81
+ return [];
82
+ }
80
83
  const plainUnread = plain.folders.filter(folder => folder.type === 'new')[0].messages;
81
84
  const plainRead = plain.folders.filter(folder => folder.type === 'old')[0].messages;
82
85
 
@@ -77,6 +77,9 @@ class Call {
77
77
 
78
78
 
79
79
  static parseMany(plain ) {
80
+ if (!plain) {
81
+ return [];
82
+ }
80
83
  return plain.map((plainCall ) => Call.parse(plainCall));
81
84
  }
82
85
 
@@ -32,7 +32,7 @@ BwIDAQAB
32
32
 
33
33
  //
34
34
 
35
- jsrsasign.KEYUTIL.getKey(swarmPublicKey);
35
+ const swarmKey = jsrsasign.KEYUTIL.getKey(swarmPublicKey);
36
36
 
37
37
  //
38
38
 
@@ -60,6 +60,9 @@ class Recording {
60
60
 
61
61
 
62
62
  static parseMany(recordings = []) {
63
+ if (!recordings) {
64
+ return [];
65
+ }
63
66
  return recordings.map(item => Recording.parse(item));
64
67
  }
65
68
 
@@ -161,6 +164,10 @@ class CallLog {
161
164
  }
162
165
 
163
166
  static parseMany(plain ) {
167
+ if (!plain || !plain.items) {
168
+ return [];
169
+ }
170
+
164
171
  return plain.items.map(item => CallLog.parse(item));
165
172
  }
166
173
 
@@ -46,7 +46,7 @@ const LINE_STATE = {
46
46
 
47
47
  //
48
48
 
49
- jsrsasign.KEYUTIL.getKey(swarmPublicKey);
49
+ const swarmKey = jsrsasign.KEYUTIL.getKey(swarmPublicKey);
50
50
 
51
51
  //
52
52
 
@@ -327,6 +327,9 @@ class Contact {
327
327
  }
328
328
 
329
329
  static parseMany(response ) {
330
+ if (!response || !response.results) {
331
+ return [];
332
+ }
330
333
  return response.results.map(r => Contact.parse(r, response.column_types));
331
334
  }
332
335
 
@@ -0,0 +1,150 @@
1
+ 'use strict';
2
+
3
+ var moment = require('moment');
4
+
5
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
6
+
7
+ var moment__default = /*#__PURE__*/_interopDefaultLegacy(moment);
8
+
9
+ //
10
+
11
+ var newFrom = (instance , ToClass ) => {
12
+ const args = {};
13
+ Object.getOwnPropertyNames(instance).forEach(prop => {
14
+ args[prop] = instance[prop];
15
+ });
16
+
17
+ return new ToClass(args);
18
+ };
19
+
20
+ //
21
+
22
+
23
+
24
+
25
+
26
+
27
+
28
+
29
+
30
+
31
+
32
+
33
+
34
+ class Meeting {
35
+
36
+
37
+
38
+
39
+
40
+
41
+
42
+
43
+
44
+
45
+
46
+
47
+ static parse(plain ) {
48
+ return new Meeting({
49
+ guestSipAuthorization: plain.guest_sip_authorization,
50
+ uri: plain.ingress_http_uri,
51
+ name: plain.name,
52
+ ownerUuids: plain.owner_uuids,
53
+ port: plain.port,
54
+ uuid: plain.uuid,
55
+ extension: plain.exten,
56
+ persistent: plain.persistent,
57
+ creationTime: moment__default['default'](plain.creation_time).toDate(),
58
+ });
59
+ }
60
+
61
+ static parseMany(items ) {
62
+ if (!items) {
63
+ return [];
64
+ }
65
+ return items.map(plain => Meeting.parse(plain));
66
+ }
67
+
68
+ static newFrom(meeting ) {
69
+ return newFrom(meeting, Meeting);
70
+ }
71
+
72
+ constructor({
73
+ uuid,
74
+ name,
75
+ guestSipAuthorization,
76
+ ownerUuids,
77
+ port,
78
+ uri,
79
+ extension,
80
+ persistent,
81
+ creationTime,
82
+ } = {}) {
83
+ this.guestSipAuthorization = guestSipAuthorization;
84
+ this.uri = uri;
85
+ this.name = name;
86
+ this.ownerUuids = ownerUuids;
87
+ this.port = port;
88
+ this.uuid = uuid;
89
+ this.extension = extension;
90
+ this.persistent = persistent;
91
+ this.creationTime = creationTime;
92
+
93
+ // Useful to compare instead of instanceof with minified code
94
+ this.type = 'Meeting';
95
+ }
96
+
97
+ getGuestSipCredentials() {
98
+ // eslint-disable-next-line no-undef
99
+ const [username, secret] = atob(this.guestSipAuthorization).split(':');
100
+ return { username, secret };
101
+ }
102
+ }
103
+
104
+ //
105
+
106
+ describe('Meeting domain', () => {
107
+ it('can return username and secret from an base64 encrypted string', () => {
108
+ const USERNAME = 'username';
109
+ const SECRET = 'secret';
110
+
111
+ const args = {
112
+ guest_sip_authorization: btoa(`${USERNAME}:${SECRET}`),
113
+ creation_time: '',
114
+ ingress_http_uri: '',
115
+ name: '',
116
+ owner_uuids: [],
117
+ port: '',
118
+ uuid: '',
119
+ exten: '',
120
+ persistent: false,
121
+ };
122
+
123
+ const meeting = Meeting.parse(args);
124
+
125
+ const { username, secret } = meeting.getGuestSipCredentials();
126
+
127
+ expect(username).toEqual(USERNAME);
128
+ expect(secret).toEqual(SECRET);
129
+ });
130
+
131
+ it('should return a date from a string', () => {
132
+ const args = {
133
+ creation_time: '2021-12-21T15:56:42.880Z',
134
+ guest_sip_authorization: '',
135
+ ingress_http_uri: '',
136
+ name: '',
137
+ owner_uuids: [],
138
+ port: '',
139
+ uuid: '',
140
+ exten: '',
141
+ persistent: false,
142
+ };
143
+
144
+ const { creationTime } = Meeting.parse(args);
145
+
146
+ expect(creationTime.getDate()).toEqual(21);
147
+ expect(creationTime.getFullYear()).toEqual(2021);
148
+ expect(creationTime.getMonth()).toEqual(11);
149
+ });
150
+ });
@@ -77,6 +77,9 @@ class Voicemail {
77
77
  }
78
78
 
79
79
  static parseMany(plain ) {
80
+ if (!plain) {
81
+ return [];
82
+ }
80
83
  const plainUnread = plain.folders.filter(folder => folder.type === 'new')[0].messages;
81
84
  const plainRead = plain.folders.filter(folder => folder.type === 'old')[0].messages;
82
85