@wazo/sdk 0.37.0-rc.5 → 0.37.2

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 (149) hide show
  1. package/dist/wazo-sdk.js +5 -5
  2. package/esm/__tests__/api-client.test.js +93 -16
  3. package/esm/__tests__/web-rtc-client.test.js +153 -54
  4. package/esm/api/agentd.js +24 -3
  5. package/esm/api/amid.js +7 -1
  6. package/esm/api/application.js +24 -3
  7. package/esm/api/auth.js +24 -3
  8. package/esm/api/call-logd.js +78 -20
  9. package/esm/api/calld.js +24 -20
  10. package/esm/api/chatd.js +24 -3
  11. package/esm/api/confd.js +24 -3
  12. package/esm/api/ctid-ng.js +24 -3
  13. package/esm/api/dird.js +27 -6
  14. package/esm/api/webhookd.js +7 -1
  15. package/esm/api-client.js +93 -16
  16. package/esm/checker/Checker.js +156 -54
  17. package/esm/checker/checks/aor.js +95 -16
  18. package/esm/checker/checks/api.js +94 -16
  19. package/esm/checker/checks/index.js +156 -54
  20. package/esm/checker/checks/wazo-websocket.js +7 -1
  21. package/esm/checker/checks/webrtc-transport.js +153 -54
  22. package/esm/checker/checks/webrtc.js +153 -54
  23. package/esm/domain/AdHocAPIConference.js +1717 -1640
  24. package/esm/domain/CallLog.js +71 -19
  25. package/esm/domain/CallSession.js +1 -18
  26. package/esm/domain/Contact.js +3 -3
  27. package/esm/domain/Features.js +93 -16
  28. package/esm/domain/IndirectTransfer.js +0 -17
  29. package/esm/domain/Phone/CTIPhone.js +100 -19
  30. package/esm/domain/Phone/Phone.js +0 -17
  31. package/esm/domain/Phone/WebRTCPhone.js +51 -36
  32. package/esm/domain/Recording.js +51 -0
  33. package/esm/domain/Room.js +0 -17
  34. package/esm/domain/SwitchboardCall.js +0 -17
  35. package/esm/domain/__tests__/CallLog.test.js +89 -19
  36. package/esm/domain/__tests__/CallSession.test.js +1 -18
  37. package/esm/domain/__tests__/Contact.test.js +3 -3
  38. package/esm/domain/__tests__/IndirectTransfer.test.js +1 -18
  39. package/esm/domain/__tests__/Room.test.js +1 -18
  40. package/esm/domain/__tests__/Session.test.js +7 -0
  41. package/esm/index.js +3436 -2911
  42. package/esm/lib/WazoSessionDescriptionHandler.js +28 -10
  43. package/esm/service/CallApi.js +93 -16
  44. package/esm/service/IssueReporter.js +7 -1
  45. package/esm/service/__tests__/IssueReporter.test.js +26 -2
  46. package/esm/service/getApiClient.js +93 -16
  47. package/esm/simple/Auth.js +619 -97
  48. package/esm/simple/Configuration.js +619 -97
  49. package/esm/simple/Directory.js +93 -16
  50. package/esm/simple/Phone.js +3261 -2739
  51. package/esm/simple/Websocket.js +7 -1
  52. package/esm/simple/index.js +619 -97
  53. package/esm/simple/room/LocalParticipant.js +619 -97
  54. package/esm/simple/room/Participant.js +619 -97
  55. package/esm/simple/room/RemoteParticipant.js +619 -97
  56. package/esm/simple/room/Room.js +619 -97
  57. package/esm/simple/room/Stream.js +619 -97
  58. package/esm/simple/room/__tests__/RemoteParticipant.test.js +619 -97
  59. package/esm/simple/utils.js +619 -97
  60. package/esm/utils/__tests__/api-requester.test.js +32 -6
  61. package/esm/utils/api-requester.js +24 -3
  62. package/esm/web-rtc-client.js +153 -54
  63. package/esm/websocket-client.js +7 -1
  64. package/lib/__tests__/api-client.test.js +93 -16
  65. package/lib/__tests__/web-rtc-client.test.js +154 -55
  66. package/lib/api/agentd.js +24 -3
  67. package/lib/api/amid.js +7 -1
  68. package/lib/api/application.js +24 -3
  69. package/lib/api/auth.js +24 -3
  70. package/lib/api/call-logd.js +78 -20
  71. package/lib/api/calld.js +24 -20
  72. package/lib/api/chatd.js +24 -3
  73. package/lib/api/confd.js +24 -3
  74. package/lib/api/ctid-ng.js +24 -3
  75. package/lib/api/dird.js +27 -6
  76. package/lib/api/webhookd.js +7 -1
  77. package/lib/api-client.js +93 -16
  78. package/lib/checker/Checker.js +157 -55
  79. package/lib/checker/checks/aor.js +95 -16
  80. package/lib/checker/checks/api.js +94 -16
  81. package/lib/checker/checks/index.js +157 -55
  82. package/lib/checker/checks/wazo-websocket.js +7 -1
  83. package/lib/checker/checks/webrtc-transport.js +154 -55
  84. package/lib/checker/checks/webrtc.js +154 -55
  85. package/lib/domain/AdHocAPIConference.js +1717 -1640
  86. package/lib/domain/CallLog.js +71 -19
  87. package/lib/domain/CallSession.js +1 -18
  88. package/lib/domain/Contact.js +3 -3
  89. package/lib/domain/Features.js +93 -16
  90. package/lib/domain/IndirectTransfer.js +0 -17
  91. package/lib/domain/Phone/CTIPhone.js +100 -19
  92. package/lib/domain/Phone/Phone.js +0 -16
  93. package/lib/domain/Phone/WebRTCPhone.js +51 -36
  94. package/lib/domain/Recording.js +57 -0
  95. package/lib/domain/Room.js +0 -17
  96. package/lib/domain/SwitchboardCall.js +0 -17
  97. package/lib/domain/__tests__/CallLog.test.js +89 -19
  98. package/lib/domain/__tests__/CallSession.test.js +1 -18
  99. package/lib/domain/__tests__/Contact.test.js +3 -3
  100. package/lib/domain/__tests__/IndirectTransfer.test.js +1 -18
  101. package/lib/domain/__tests__/Room.test.js +1 -18
  102. package/lib/domain/__tests__/Session.test.js +7 -0
  103. package/lib/index.js +3437 -2912
  104. package/lib/lib/WazoSessionDescriptionHandler.js +28 -10
  105. package/lib/service/CallApi.js +93 -16
  106. package/lib/service/IssueReporter.js +7 -1
  107. package/lib/service/__tests__/IssueReporter.test.js +26 -2
  108. package/lib/service/getApiClient.js +93 -16
  109. package/lib/simple/Auth.js +620 -98
  110. package/lib/simple/Configuration.js +620 -98
  111. package/lib/simple/Directory.js +93 -16
  112. package/lib/simple/Phone.js +3262 -2740
  113. package/lib/simple/Websocket.js +7 -1
  114. package/lib/simple/index.js +620 -98
  115. package/lib/simple/room/LocalParticipant.js +620 -98
  116. package/lib/simple/room/Participant.js +620 -98
  117. package/lib/simple/room/RemoteParticipant.js +620 -98
  118. package/lib/simple/room/Room.js +620 -98
  119. package/lib/simple/room/Stream.js +620 -98
  120. package/lib/simple/room/__tests__/RemoteParticipant.test.js +620 -98
  121. package/lib/simple/utils.js +620 -98
  122. package/lib/utils/__tests__/api-requester.test.js +32 -6
  123. package/lib/utils/api-requester.js +24 -3
  124. package/lib/web-rtc-client.js +154 -55
  125. package/lib/websocket-client.js +7 -1
  126. package/package.json +1 -1
  127. package/src/api-client.js +4 -0
  128. package/src/checker/checks/aor.js +2 -0
  129. package/src/checker/checks/api.js +1 -0
  130. package/src/domain/CallLog.js +18 -11
  131. package/src/domain/CallSession.js +1 -2
  132. package/src/domain/Contact.js +3 -3
  133. package/src/domain/Phone/CTIPhone.js +6 -2
  134. package/src/domain/Phone/Phone.js +2 -0
  135. package/src/domain/Phone/WebRTCPhone.js +26 -16
  136. package/src/domain/Recording.js +48 -0
  137. package/src/domain/__tests__/CallLog.test.js +19 -0
  138. package/src/domain/__tests__/Session.test.js +7 -0
  139. package/src/index.js +6 -0
  140. package/src/lib/WazoSessionDescriptionHandler.js +21 -9
  141. package/src/service/IssueReporter.js +7 -1
  142. package/src/service/__tests__/IssueReporter.test.js +20 -1
  143. package/src/simple/Phone.js +5 -1
  144. package/src/simple/index.js +6 -0
  145. package/src/simple/room/Room.js +18 -15
  146. package/src/simple/room/Stream.js +1 -4
  147. package/src/utils/__tests__/api-requester.test.js +9 -4
  148. package/src/utils/api-requester.js +17 -2
  149. package/src/web-rtc-client.js +40 -13
@@ -3,6 +3,17 @@ import { KEYUTIL } from 'jsrsasign';
3
3
 
4
4
  //
5
5
 
6
+ var newFrom = (instance , ToClass ) => {
7
+ const args = {};
8
+ Object.getOwnPropertyNames(instance).forEach(prop => {
9
+ args[prop] = instance[prop];
10
+ });
11
+
12
+ return new ToClass(args);
13
+ };
14
+
15
+ //
16
+
6
17
  const swarmPublicKey = `-----BEGIN PUBLIC KEY-----
7
18
  MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmkXOuNfY8u5xoTiIhkb8
8
19
  djnbIwG/Wrz3vpo8BZir8L5e1a1nSy740qBjP7ZINBQoALDhFfmdOfJnCyEGiHuz
@@ -15,32 +26,70 @@ BwIDAQAB
15
26
 
16
27
  //
17
28
 
18
- var newFrom = (instance , ToClass ) => {
19
- const args = {};
20
- Object.getOwnPropertyNames(instance).forEach(prop => {
21
- args[prop] = instance[prop];
22
- });
23
-
24
- return new ToClass(args);
25
- };
29
+ KEYUTIL.getKey(swarmPublicKey);
26
30
 
27
31
  //
28
32
 
29
- KEYUTIL.getKey(swarmPublicKey);
33
+
34
+
35
+
36
+
37
+
38
+
39
+
40
+
41
+
42
+
43
+
44
+
45
+
46
+
47
+
48
+
49
+ class Recording {
50
+
51
+
52
+
53
+
54
+
55
+
56
+ static parseMany(recordings ) {
57
+ return recordings.map(item => Recording.parse(item));
58
+ }
59
+
60
+ static parse(plain ) {
61
+ return new Recording({
62
+ deleted: plain.deleted,
63
+ fileName: plain.filename,
64
+ end: plain.end_time ? moment(plain.end_time).toDate() : null,
65
+ start: moment(plain.start_time).toDate(),
66
+ uuid: plain.uuid,
67
+ });
68
+ }
69
+
70
+ constructor({ deleted, end, fileName, start, uuid } ) {
71
+ this.deleted = deleted;
72
+ this.end = end;
73
+ this.fileName = fileName;
74
+ this.start = start;
75
+ this.uuid = uuid;
76
+ }
77
+ }
30
78
 
31
79
  //
32
80
 
33
81
 
34
-
82
+
35
83
 
36
84
 
37
85
 
38
86
 
39
87
 
40
-
88
+
41
89
 
42
90
 
43
91
 
92
+
44
93
 
45
94
 
46
95
 
@@ -53,7 +102,7 @@ KEYUTIL.getKey(swarmPublicKey);
53
102
 
54
103
 
55
104
 
56
-
105
+
57
106
 
58
107
 
59
108
 
@@ -68,13 +117,14 @@ KEYUTIL.getKey(swarmPublicKey);
68
117
 
69
118
 
70
119
 
71
-
120
+
121
+
72
122
 
73
123
 
74
124
  class CallLog {
75
125
 
76
126
 
77
-
127
+
78
128
 
79
129
 
80
130
 
@@ -91,7 +141,7 @@ class CallLog {
91
141
 
92
142
 
93
143
 
94
-
144
+
95
145
 
96
146
  static merge(current , toMerge ) {
97
147
  const onlyUnique = (value, index, self) => self.indexOf(value) === index;
@@ -108,7 +158,7 @@ class CallLog {
108
158
 
109
159
  static parse(plain ) {
110
160
  return new CallLog({
111
- answer: moment(plain.answer).toDate(),
161
+ answer: plain.answer ? moment(plain.answer).toDate() : null,
112
162
  answered: plain.answered,
113
163
  callDirection: plain.call_direction,
114
164
  destination: {
@@ -122,13 +172,14 @@ class CallLog {
122
172
  id: plain.id,
123
173
  duration: (plain.duration || 0) * 1000, // duration is in seconds
124
174
  start: moment(plain.start).toDate(),
125
- end: moment(plain.end).toDate(),
175
+ end: plain.end ? moment(plain.end).toDate() : null,
176
+ recordings: Recording.parseMany(plain.recordings),
126
177
  });
127
178
  }
128
179
 
129
180
  static parseNew(plain , session ) {
130
181
  return new CallLog({
131
- answer: moment(plain.answer).toDate(),
182
+ answer: plain.answer ? moment(plain.answer).toDate() : null,
132
183
  answered: plain.answered,
133
184
  callDirection: plain.call_direction,
134
185
  destination: {
@@ -142,7 +193,8 @@ class CallLog {
142
193
  id: plain.id,
143
194
  duration: (plain.duration || 0) * 1000, // duration is in seconds
144
195
  start: moment(plain.start).toDate(),
145
- end: moment(plain.end).toDate(),
196
+ end: plain.end ? moment(plain.end).toDate() : null,
197
+ recordings: Recording.parseMany(plain.recordings),
146
198
  // @TODO: FIXME add verification declined vs missed call
147
199
  newMissedCall: session
148
200
  && session.hasExtension(plain.requested_extension || plain.destination_extension) && !plain.answered,
@@ -276,6 +328,15 @@ describe('CallLog domain', () => {
276
328
  requested_extension: '',
277
329
  requested_name: '',
278
330
  id: 215,
331
+ recordings: [
332
+ {
333
+ deleted: false,
334
+ end_time: '2021-08-11T13:22:50.519733+00:00',
335
+ filename: '2021-08-11T13_22_45UTC-61886-xxxx-5c72-4072-8503-e3ad9a41c0a0.wav',
336
+ start_time: '2021-08-11T13:22:45.161954+00:00',
337
+ uuid: '0394ad6f-5c72-4072-8503-e3ad9a41c0a0',
338
+ },
339
+ ],
279
340
  },
280
341
  ],
281
342
  total: 233,
@@ -300,6 +361,15 @@ describe('CallLog domain', () => {
300
361
  duration: 4000,
301
362
  start: moment('2017-08-06T13:50:55.819057+00:00').toDate(),
302
363
  end: moment('2017-08-08T13:51:23.822529+00:00').toDate(),
364
+ recordings: [
365
+ new Recording({
366
+ deleted: false,
367
+ end: moment('2021-08-11T13:22:50.519733+00:00').toDate(),
368
+ fileName: '2021-08-11T13_22_45UTC-61886-xxxx-5c72-4072-8503-e3ad9a41c0a0.wav',
369
+ start: moment('2021-08-11T13:22:45.161954+00:00').toDate(),
370
+ uuid: '0394ad6f-5c72-4072-8503-e3ad9a41c0a0',
371
+ }),
372
+ ],
303
373
  }),
304
374
  ]);
305
375
  });
@@ -1,6 +1,5 @@
1
1
  import { SessionState } from 'sip.js/lib/api/session-state';
2
2
  import 'moment';
3
- import { KEYUTIL } from 'jsrsasign';
4
3
 
5
4
  //
6
5
 
@@ -13,22 +12,6 @@ var newFrom = (instance , ToClass ) => {
13
12
  return new ToClass(args);
14
13
  };
15
14
 
16
- //
17
-
18
- const swarmPublicKey = `-----BEGIN PUBLIC KEY-----
19
- MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmkXOuNfY8u5xoTiIhkb8
20
- djnbIwG/Wrz3vpo8BZir8L5e1a1nSy740qBjP7ZINBQoALDhFfmdOfJnCyEGiHuz
21
- ZW6jbG6C3PryE3Bu6GKwqSmD6k3q4Zk27fpwYAnNl+rWhYYM563rJZBda/INyHNN
22
- pK7M1mixWi7gNdjjXwoEXSSBx+VpYMkY6LiAB2mvHXTY9M1qI14dvgGoQISZQoKi
23
- NMTRCg5UP2ic0Dd9nSz/XpcOxGfa+0fwIl1F7RC1tJXOqvkGGPTOV4LLfg/Yta3h
24
- nUPX9EZZDIX6vO/0IBV1LzjSl2A1bYFYAjJfowv3i1CpvONBOClHjSY5t9Y8MH6p
25
- BwIDAQAB
26
- -----END PUBLIC KEY-----`;
27
-
28
- //
29
-
30
- KEYUTIL.getKey(swarmPublicKey);
31
-
32
15
  //
33
16
  /* eslint-disable no-param-reassign */
34
17
 
@@ -352,7 +335,7 @@ class CallSession {
352
335
  return newFrom(callSession, CallSession);
353
336
  }
354
337
 
355
- static parseCall(session , call ) {
338
+ static parseCall(call ) {
356
339
  return new CallSession({
357
340
  callId: call.id,
358
341
  sipCallId: call.sipCallId,
@@ -464,7 +464,7 @@ class Contact {
464
464
 
465
465
  return new Contact({
466
466
  sourceId: single.id || '',
467
- name: single.displayName,
467
+ name: single.displayName || '',
468
468
  number: numbers.length ? numbers[0].number : '',
469
469
  numbers,
470
470
  emails,
@@ -495,7 +495,7 @@ class Contact {
495
495
 
496
496
  return new Contact({
497
497
  sourceId: single.id || '',
498
- name: single.name,
498
+ name: single.name || '',
499
499
  number: numbers.length ? numbers[0].number : '',
500
500
  numbers,
501
501
  emails,
@@ -596,7 +596,7 @@ class Contact {
596
596
  } = {}) {
597
597
  this.id = id;
598
598
  this.uuid = uuid;
599
- this.name = name;
599
+ this.name = name || '';
600
600
  this.number = number;
601
601
  this.numbers = numbers;
602
602
  this.email = email;
@@ -1,6 +1,5 @@
1
1
  import { SessionState } from 'sip.js/lib/api/session-state';
2
2
  import 'moment';
3
- import { KEYUTIL } from 'jsrsasign';
4
3
 
5
4
  //
6
5
 
@@ -13,22 +12,6 @@ var newFrom = (instance , ToClass ) => {
13
12
  return new ToClass(args);
14
13
  };
15
14
 
16
- //
17
-
18
- const swarmPublicKey = `-----BEGIN PUBLIC KEY-----
19
- MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmkXOuNfY8u5xoTiIhkb8
20
- djnbIwG/Wrz3vpo8BZir8L5e1a1nSy740qBjP7ZINBQoALDhFfmdOfJnCyEGiHuz
21
- ZW6jbG6C3PryE3Bu6GKwqSmD6k3q4Zk27fpwYAnNl+rWhYYM563rJZBda/INyHNN
22
- pK7M1mixWi7gNdjjXwoEXSSBx+VpYMkY6LiAB2mvHXTY9M1qI14dvgGoQISZQoKi
23
- NMTRCg5UP2ic0Dd9nSz/XpcOxGfa+0fwIl1F7RC1tJXOqvkGGPTOV4LLfg/Yta3h
24
- nUPX9EZZDIX6vO/0IBV1LzjSl2A1bYFYAjJfowv3i1CpvONBOClHjSY5t9Y8MH6p
25
- BwIDAQAB
26
- -----END PUBLIC KEY-----`;
27
-
28
- //
29
-
30
- KEYUTIL.getKey(swarmPublicKey);
31
-
32
15
  //
33
16
  /* eslint-disable no-param-reassign */
34
17
 
@@ -352,7 +335,7 @@ class CallSession {
352
335
  return newFrom(callSession, CallSession);
353
336
  }
354
337
 
355
- static parseCall(session , call ) {
338
+ static parseCall(call ) {
356
339
  return new CallSession({
357
340
  callId: call.id,
358
341
  sipCallId: call.sipCallId,
@@ -1,6 +1,5 @@
1
1
  import { SessionState } from 'sip.js/lib/api/session-state';
2
2
  import 'moment';
3
- import { KEYUTIL } from 'jsrsasign';
4
3
 
5
4
  //
6
5
 
@@ -13,22 +12,6 @@ var newFrom = (instance , ToClass ) => {
13
12
  return new ToClass(args);
14
13
  };
15
14
 
16
- //
17
-
18
- const swarmPublicKey = `-----BEGIN PUBLIC KEY-----
19
- MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmkXOuNfY8u5xoTiIhkb8
20
- djnbIwG/Wrz3vpo8BZir8L5e1a1nSy740qBjP7ZINBQoALDhFfmdOfJnCyEGiHuz
21
- ZW6jbG6C3PryE3Bu6GKwqSmD6k3q4Zk27fpwYAnNl+rWhYYM563rJZBda/INyHNN
22
- pK7M1mixWi7gNdjjXwoEXSSBx+VpYMkY6LiAB2mvHXTY9M1qI14dvgGoQISZQoKi
23
- NMTRCg5UP2ic0Dd9nSz/XpcOxGfa+0fwIl1F7RC1tJXOqvkGGPTOV4LLfg/Yta3h
24
- nUPX9EZZDIX6vO/0IBV1LzjSl2A1bYFYAjJfowv3i1CpvONBOClHjSY5t9Y8MH6p
25
- BwIDAQAB
26
- -----END PUBLIC KEY-----`;
27
-
28
- //
29
-
30
- KEYUTIL.getKey(swarmPublicKey);
31
-
32
15
  //
33
16
  /* eslint-disable no-param-reassign */
34
17
 
@@ -352,7 +335,7 @@ class CallSession {
352
335
  return newFrom(callSession, CallSession);
353
336
  }
354
337
 
355
- static parseCall(session , call ) {
338
+ static parseCall(call ) {
356
339
  return new CallSession({
357
340
  callId: call.id,
358
341
  sipCallId: call.sipCallId,
@@ -1028,7 +1028,14 @@ describe('Session domain', () => {
1028
1028
  const acl = ['calld.lines.*.presences.read'];
1029
1029
  const session = new Session({ acl, expiresAt: new Date(), token: 'abc' });
1030
1030
 
1031
+ const oldWarn = console.warn;
1032
+ // $FlowFixMe
1033
+ console.warn = () => {};
1034
+
1031
1035
  expect(session.acls).toEqual(acl);
1032
1036
  expect(session.acl).toEqual(acl);
1037
+
1038
+ // $FlowFixMe
1039
+ console.warn = oldWarn;
1033
1040
  });
1034
1041
  });