@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
@@ -983,7 +983,7 @@ class Contact {
983
983
 
984
984
  return new Contact({
985
985
  sourceId: single.id || '',
986
- name: single.displayName,
986
+ name: single.displayName || '',
987
987
  number: numbers.length ? numbers[0].number : '',
988
988
  numbers,
989
989
  emails,
@@ -1014,7 +1014,7 @@ class Contact {
1014
1014
 
1015
1015
  return new Contact({
1016
1016
  sourceId: single.id || '',
1017
- name: single.name,
1017
+ name: single.name || '',
1018
1018
  number: numbers.length ? numbers[0].number : '',
1019
1019
  numbers,
1020
1020
  emails,
@@ -1115,7 +1115,7 @@ class Contact {
1115
1115
  } = {}) {
1116
1116
  this.id = id;
1117
1117
  this.uuid = uuid;
1118
- this.name = name;
1118
+ this.name = name || '';
1119
1119
  this.number = number;
1120
1120
  this.numbers = numbers;
1121
1121
  this.email = email;
@@ -1999,7 +1999,7 @@ class CallSession {
1999
1999
  return newFrom(callSession, CallSession);
2000
2000
  }
2001
2001
 
2002
- static parseCall(session , call ) {
2002
+ static parseCall(call ) {
2003
2003
  return new CallSession({
2004
2004
  callId: call.id,
2005
2005
  sipCallId: call.sipCallId,
@@ -2052,17 +2052,66 @@ class Emitter {
2052
2052
 
2053
2053
  //
2054
2054
 
2055
+
2056
+
2057
+
2058
+
2059
+
2060
+
2061
+
2062
+
2063
+
2064
+
2065
+
2066
+
2067
+
2068
+
2069
+
2070
+
2071
+ class Recording {
2072
+
2073
+
2074
+
2075
+
2076
+
2077
+
2078
+ static parseMany(recordings ) {
2079
+ return recordings.map(item => Recording.parse(item));
2080
+ }
2081
+
2082
+ static parse(plain ) {
2083
+ return new Recording({
2084
+ deleted: plain.deleted,
2085
+ fileName: plain.filename,
2086
+ end: plain.end_time ? moment(plain.end_time).toDate() : null,
2087
+ start: moment(plain.start_time).toDate(),
2088
+ uuid: plain.uuid,
2089
+ });
2090
+ }
2091
+
2092
+ constructor({ deleted, end, fileName, start, uuid } ) {
2093
+ this.deleted = deleted;
2094
+ this.end = end;
2095
+ this.fileName = fileName;
2096
+ this.start = start;
2097
+ this.uuid = uuid;
2098
+ }
2099
+ }
2100
+
2101
+ //
2102
+
2055
2103
 
2056
-
2104
+
2057
2105
 
2058
2106
 
2059
2107
 
2060
2108
 
2061
2109
 
2062
-
2110
+
2063
2111
 
2064
2112
 
2065
2113
 
2114
+
2066
2115
 
2067
2116
 
2068
2117
 
@@ -2075,7 +2124,7 @@ class Emitter {
2075
2124
 
2076
2125
 
2077
2126
 
2078
-
2127
+
2079
2128
 
2080
2129
 
2081
2130
 
@@ -2090,13 +2139,14 @@ class Emitter {
2090
2139
 
2091
2140
 
2092
2141
 
2093
-
2142
+
2143
+
2094
2144
 
2095
2145
 
2096
2146
  class CallLog {
2097
2147
 
2098
2148
 
2099
-
2149
+
2100
2150
 
2101
2151
 
2102
2152
 
@@ -2113,7 +2163,7 @@ class CallLog {
2113
2163
 
2114
2164
 
2115
2165
 
2116
-
2166
+
2117
2167
 
2118
2168
  static merge(current , toMerge ) {
2119
2169
  const onlyUnique = (value, index, self) => self.indexOf(value) === index;
@@ -2130,7 +2180,7 @@ class CallLog {
2130
2180
 
2131
2181
  static parse(plain ) {
2132
2182
  return new CallLog({
2133
- answer: moment(plain.answer).toDate(),
2183
+ answer: plain.answer ? moment(plain.answer).toDate() : null,
2134
2184
  answered: plain.answered,
2135
2185
  callDirection: plain.call_direction,
2136
2186
  destination: {
@@ -2144,13 +2194,14 @@ class CallLog {
2144
2194
  id: plain.id,
2145
2195
  duration: (plain.duration || 0) * 1000, // duration is in seconds
2146
2196
  start: moment(plain.start).toDate(),
2147
- end: moment(plain.end).toDate(),
2197
+ end: plain.end ? moment(plain.end).toDate() : null,
2198
+ recordings: Recording.parseMany(plain.recordings),
2148
2199
  });
2149
2200
  }
2150
2201
 
2151
2202
  static parseNew(plain , session ) {
2152
2203
  return new CallLog({
2153
- answer: moment(plain.answer).toDate(),
2204
+ answer: plain.answer ? moment(plain.answer).toDate() : null,
2154
2205
  answered: plain.answered,
2155
2206
  callDirection: plain.call_direction,
2156
2207
  destination: {
@@ -2164,7 +2215,8 @@ class CallLog {
2164
2215
  id: plain.id,
2165
2216
  duration: (plain.duration || 0) * 1000, // duration is in seconds
2166
2217
  start: moment(plain.start).toDate(),
2167
- end: moment(plain.end).toDate(),
2218
+ end: plain.end ? moment(plain.end).toDate() : null,
2219
+ recordings: Recording.parseMany(plain.recordings),
2168
2220
  // @TODO: FIXME add verification declined vs missed call
2169
2221
  newMissedCall: session
2170
2222
  && session.hasExtension(plain.requested_extension || plain.destination_extension) && !plain.answered,
@@ -2624,7 +2676,13 @@ class IssueReporter {
2624
2676
  }
2625
2677
 
2626
2678
  _isLevelAbove(level1 , level2 ) {
2627
- return LOG_LEVELS.indexOf(level1) > LOG_LEVELS.indexOf(level2);
2679
+ const index1 = LOG_LEVELS.indexOf(level1);
2680
+ const index2 = LOG_LEVELS.indexOf(level2);
2681
+ if (index1 === -1 || index2 === -1) {
2682
+ return false;
2683
+ }
2684
+
2685
+ return index1 > index2;
2628
2686
  }
2629
2687
 
2630
2688
  _makeCategory(category ) {
@@ -2682,6 +2740,7 @@ class ApiRequester {
2682
2740
 
2683
2741
 
2684
2742
 
2743
+
2685
2744
 
2686
2745
 
2687
2746
 
@@ -2721,6 +2780,8 @@ class ApiRequester {
2721
2780
  this.token = token;
2722
2781
  }
2723
2782
 
2783
+ this.shouldLogErrors = true;
2784
+
2724
2785
  methods.forEach(method => {
2725
2786
  // $FlowFixMe
2726
2787
  ApiRequester.prototype[method] = function sugar(...args) {
@@ -2744,6 +2805,14 @@ class ApiRequester {
2744
2805
  this.fetchOptions = options;
2745
2806
  }
2746
2807
 
2808
+ disableErrorLogging() {
2809
+ this.shouldLogErrors = false;
2810
+ }
2811
+
2812
+ enableErrorLogging() {
2813
+ this.shouldLogErrors = true;
2814
+ }
2815
+
2747
2816
  async call(
2748
2817
  path ,
2749
2818
  method = 'get',
@@ -2804,7 +2873,9 @@ class ApiRequester {
2804
2873
  ? exceptionClass.fromText(err, response.status)
2805
2874
  : exceptionClass.fromResponse(err, response.status);
2806
2875
 
2807
- logger$2.error('API error', error);
2876
+ if (this.shouldLogErrors) {
2877
+ logger$2.error('API error', error);
2878
+ }
2808
2879
 
2809
2880
  throw error;
2810
2881
  });
@@ -2812,7 +2883,9 @@ class ApiRequester {
2812
2883
 
2813
2884
  return newParse(response, isJson);
2814
2885
  }).catch(error => {
2815
- logger$2.error('Fetch failed', { url, options, message: error.message, stack: error.stack });
2886
+ if (this.shouldLogErrors) {
2887
+ logger$2.error('Fetch failed', { url, options, message: error.message, stack: error.stack });
2888
+ }
2816
2889
 
2817
2890
  throw error;
2818
2891
  });
@@ -4672,6 +4745,10 @@ class ApiClient {
4672
4745
  this.fetchOptions = fetchOptions;
4673
4746
  this.client.setFetchOptions(fetchOptions);
4674
4747
  }
4748
+
4749
+ disableErrorLogging() {
4750
+ this.client.disableErrorLogging();
4751
+ }
4675
4752
  }
4676
4753
 
4677
4754
  /* eslint-disable dot-notation */
@@ -4904,7 +4981,7 @@ class CTIPhone extends Emitter {
4904
4981
  if (!this.currentCall) {
4905
4982
  return null;
4906
4983
  }
4907
- const callSession = CallSession.parseCall(this.session, this.currentCall);
4984
+ const callSession = CallSession.parseCall(this.currentCall);
4908
4985
  this.eventEmitter.emit('onCallOutgoing', callSession);
4909
4986
 
4910
4987
  return callSession;
@@ -5088,6 +5165,10 @@ class CTIPhone extends Emitter {
5088
5165
  return null;
5089
5166
  }
5090
5167
 
5168
+ getLocalVideoStream() {
5169
+ return null;
5170
+ }
5171
+
5091
5172
  setActiveSipSession() {}
5092
5173
 
5093
5174
  isRegistered() {
@@ -5103,7 +5184,7 @@ class CTIPhone extends Emitter {
5103
5184
  }
5104
5185
 
5105
5186
  getCurrentCallSession() {
5106
- return this.currentCall ? CallSession.parseCall(this.session, this.currentCall) : null;
5187
+ return this.currentCall ? CallSession.parseCall(this.currentCall) : null;
5107
5188
  }
5108
5189
 
5109
5190
  enableRinging() {}
@@ -1,19 +1,2 @@
1
1
  import 'sip.js/lib/api/session-state';
2
2
  import 'moment';
3
- import { KEYUTIL } from 'jsrsasign';
4
-
5
- //
6
-
7
- const swarmPublicKey = `-----BEGIN PUBLIC KEY-----
8
- MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmkXOuNfY8u5xoTiIhkb8
9
- djnbIwG/Wrz3vpo8BZir8L5e1a1nSy740qBjP7ZINBQoALDhFfmdOfJnCyEGiHuz
10
- ZW6jbG6C3PryE3Bu6GKwqSmD6k3q4Zk27fpwYAnNl+rWhYYM563rJZBda/INyHNN
11
- pK7M1mixWi7gNdjjXwoEXSSBx+VpYMkY6LiAB2mvHXTY9M1qI14dvgGoQISZQoKi
12
- NMTRCg5UP2ic0Dd9nSz/XpcOxGfa+0fwIl1F7RC1tJXOqvkGGPTOV4LLfg/Yta3h
13
- nUPX9EZZDIX6vO/0IBV1LzjSl2A1bYFYAjJfowv3i1CpvONBOClHjSY5t9Y8MH6p
14
- BwIDAQAB
15
- -----END PUBLIC KEY-----`;
16
-
17
- //
18
-
19
- KEYUTIL.getKey(swarmPublicKey);
@@ -1,10 +1,8 @@
1
1
  import { Invitation } from 'sip.js/lib/api/invitation';
2
2
  import { SessionState } from 'sip.js/lib/api/session-state';
3
3
  import moment from 'moment';
4
- import { KEYUTIL } from 'jsrsasign';
5
4
  import 'webrtc-adapter';
6
5
  import 'sip.js/lib/api/user-agent-state';
7
- import 'sip.js/lib/api/message';
8
6
  import 'sip.js/lib/core/messages/parser';
9
7
  import 'sip.js/lib/core/messages/methods/constants';
10
8
  import 'sip.js/lib/grammar/uri';
@@ -22,6 +20,7 @@ import 'sip.js/lib/platform/web/session-description-handler/session-description-
22
20
  import 'sip.js/lib/platform/web/session-description-handler/session-description-handler-options';
23
21
  import 'js-base64';
24
22
  import 'sdp-transform';
23
+ import { KEYUTIL } from 'jsrsasign';
25
24
  import 'json-to-graphql-query/lib/jsonToGraphQLQuery';
26
25
 
27
26
  //
@@ -35,22 +34,6 @@ var newFrom = (instance , ToClass ) => {
35
34
  return new ToClass(args);
36
35
  };
37
36
 
38
- //
39
-
40
- const swarmPublicKey = `-----BEGIN PUBLIC KEY-----
41
- MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmkXOuNfY8u5xoTiIhkb8
42
- djnbIwG/Wrz3vpo8BZir8L5e1a1nSy740qBjP7ZINBQoALDhFfmdOfJnCyEGiHuz
43
- ZW6jbG6C3PryE3Bu6GKwqSmD6k3q4Zk27fpwYAnNl+rWhYYM563rJZBda/INyHNN
44
- pK7M1mixWi7gNdjjXwoEXSSBx+VpYMkY6LiAB2mvHXTY9M1qI14dvgGoQISZQoKi
45
- NMTRCg5UP2ic0Dd9nSz/XpcOxGfa+0fwIl1F7RC1tJXOqvkGGPTOV4LLfg/Yta3h
46
- nUPX9EZZDIX6vO/0IBV1LzjSl2A1bYFYAjJfowv3i1CpvONBOClHjSY5t9Y8MH6p
47
- BwIDAQAB
48
- -----END PUBLIC KEY-----`;
49
-
50
- //
51
-
52
- KEYUTIL.getKey(swarmPublicKey);
53
-
54
37
  //
55
38
  /* eslint-disable no-param-reassign */
56
39
 
@@ -374,7 +357,7 @@ class CallSession {
374
357
  return newFrom(callSession, CallSession);
375
358
  }
376
359
 
377
- static parseCall(session , call ) {
360
+ static parseCall(call ) {
378
361
  return new CallSession({
379
362
  callId: call.id,
380
363
  sipCallId: call.sipCallId,
@@ -670,7 +653,13 @@ class IssueReporter {
670
653
  }
671
654
 
672
655
  _isLevelAbove(level1 , level2 ) {
673
- return LOG_LEVELS.indexOf(level1) > LOG_LEVELS.indexOf(level2);
656
+ const index1 = LOG_LEVELS.indexOf(level1);
657
+ const index2 = LOG_LEVELS.indexOf(level2);
658
+ if (index1 === -1 || index2 === -1) {
659
+ return false;
660
+ }
661
+
662
+ return index1 > index2;
674
663
  }
675
664
 
676
665
  _makeCategory(category ) {
@@ -729,6 +718,22 @@ class Emitter {
729
718
  }
730
719
  }
731
720
 
721
+ //
722
+
723
+ const swarmPublicKey = `-----BEGIN PUBLIC KEY-----
724
+ MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmkXOuNfY8u5xoTiIhkb8
725
+ djnbIwG/Wrz3vpo8BZir8L5e1a1nSy740qBjP7ZINBQoALDhFfmdOfJnCyEGiHuz
726
+ ZW6jbG6C3PryE3Bu6GKwqSmD6k3q4Zk27fpwYAnNl+rWhYYM563rJZBda/INyHNN
727
+ pK7M1mixWi7gNdjjXwoEXSSBx+VpYMkY6LiAB2mvHXTY9M1qI14dvgGoQISZQoKi
728
+ NMTRCg5UP2ic0Dd9nSz/XpcOxGfa+0fwIl1F7RC1tJXOqvkGGPTOV4LLfg/Yta3h
729
+ nUPX9EZZDIX6vO/0IBV1LzjSl2A1bYFYAjJfowv3i1CpvONBOClHjSY5t9Y8MH6p
730
+ BwIDAQAB
731
+ -----END PUBLIC KEY-----`;
732
+
733
+ //
734
+
735
+ KEYUTIL.getKey(swarmPublicKey);
736
+
732
737
  /* eslint-disable dot-notation */
733
738
 
734
739
  // Can't use node cache mechanism here because when requiring lib/CallApi.js
@@ -936,9 +941,14 @@ class WebRTCPhone extends Emitter {
936
941
  return true;
937
942
  }
938
943
 
939
- async sendReinvite(callSession , constraints = null, conference = false) {
944
+ async sendReinvite(callSession , constraints = null, conference = false,
945
+ audioOnly = false) {
940
946
  const sipSession = this.findSipSession(callSession);
941
- logger.info('WebRTC phone - send reinvite', { sessionId: sipSession ? sipSession.id : null, constraints });
947
+ logger.info('WebRTC phone - send reinvite', {
948
+ sessionId: sipSession ? sipSession.id : null,
949
+ constraints,
950
+ audioOnly,
951
+ });
942
952
 
943
953
  if (!sipSession) {
944
954
  return null;
@@ -964,7 +974,7 @@ class WebRTCPhone extends Emitter {
964
974
  // Force reinvite in SDH
965
975
  sipSession.sessionDescriptionHandler.localMediaStreamConstraints = null;
966
976
 
967
- return this.client.reinvite(sipSession, constraints, conference);
977
+ return this.client.reinvite(sipSession, constraints, conference, audioOnly);
968
978
  }
969
979
 
970
980
  getUserAgent() {
@@ -1040,9 +1050,9 @@ class WebRTCPhone extends Emitter {
1040
1050
  }
1041
1051
 
1042
1052
  // Release local video stream when downgrading to audio
1043
- const localVideoStream = sipSession.sessionDescriptionHandler.localMediaStream;
1053
+ const localStream = sipSession.sessionDescriptionHandler.localMediaStream;
1044
1054
  const pc = sipSession.sessionDescriptionHandler.peerConnection;
1045
- const videoTracks = localVideoStream.getVideoTracks();
1055
+ const videoTracks = localStream.getVideoTracks();
1046
1056
 
1047
1057
  // Remove video senders
1048
1058
  pc.getSenders().filter(sender => sender.track && sender.track.kind === 'video').forEach(videoSender => {
@@ -1057,7 +1067,7 @@ class WebRTCPhone extends Emitter {
1057
1067
  videoTracks.forEach(videoTrack => {
1058
1068
  videoTrack.enabled = false;
1059
1069
  videoTrack.stop();
1060
- localVideoStream.removeTrack(videoTrack);
1070
+ localStream.removeTrack(videoTrack);
1061
1071
  });
1062
1072
 
1063
1073
  this._sendReinviteMessage(callSession, false);
@@ -1074,12 +1084,14 @@ class WebRTCPhone extends Emitter {
1074
1084
 
1075
1085
  const pc = sipSession.sessionDescriptionHandler.peerConnection;
1076
1086
  const shouldScreenShare = constraints && constraints.screen;
1087
+ const options = sipSession.sessionDescriptionHandlerOptionsReInvite;
1088
+ const wasAudioOnly = options && options.audioOnly;
1077
1089
 
1078
1090
  // Check if a video sender already exists
1079
1091
  let videoSender;
1080
1092
  if (isConference) {
1081
1093
  const trans = pc.getTransceivers().find(transceiver => transceiver.mid === '1');
1082
- videoSender = trans.sender;
1094
+ videoSender = trans ? trans.sender : null;
1083
1095
  } else {
1084
1096
  videoSender = pc.getSenders().find(sender => sender.track === null);
1085
1097
  }
@@ -1116,6 +1128,11 @@ class WebRTCPhone extends Emitter {
1116
1128
  this._onScreenSharing(newStream, sipSession, callSession, false);
1117
1129
  }
1118
1130
 
1131
+ // We have to reinvite to change the direction on the bundle when upgrading from an audioOnly conference
1132
+ if (isConference && wasAudioOnly) {
1133
+ return true;
1134
+ }
1135
+
1119
1136
  // No reinvite needed here
1120
1137
  return false;
1121
1138
  }
@@ -1200,7 +1217,7 @@ class WebRTCPhone extends Emitter {
1200
1217
  event.track.enabled = false;
1201
1218
  }
1202
1219
 
1203
- return this.eventEmitter.emit(ON_VIDEO_STREAM, stream, event.track.id, event);
1220
+ return this.eventEmitter.emit(ON_VIDEO_STREAM, stream, event.track.id, event, sipSession);
1204
1221
  };
1205
1222
 
1206
1223
  peerConnection.onremovestream = event => {
@@ -1256,14 +1273,11 @@ class WebRTCPhone extends Emitter {
1256
1273
  const targetCallSession = callSession || this.currentCallSession;
1257
1274
  const conference = this.isConference(targetCallSession);
1258
1275
 
1259
- if (this.currentScreenShare.sender && this.currentScreenShare.hadVideo) {
1260
- // When stopping screenshare and we had video before that, we have to re-upgrade
1261
- await this.sendReinvite(targetCallSession, { audio: false, video: true }, conference);
1262
- } else {
1263
- // When upgrading directly to screenshare (eg: we don't have a videoLocalStream to replace)
1264
- // We have to downgrade to audio.
1265
- await this.sendReinvite(targetCallSession, { audio: false, video: false }, conference);
1266
- }
1276
+ // When stopping screenshare and we had video before that, we have to re-upgrade
1277
+ // When upgrading directly to screenshare (eg: we don't have a videoLocalStream to replace)
1278
+ // We have to downgrade to audio.
1279
+ const screenshareStopped = this.currentScreenShare.sender && this.currentScreenShare.hadVideo;
1280
+ await this.sendReinvite(targetCallSession, { audio: false, video: screenshareStopped }, conference);
1267
1281
  }
1268
1282
  } catch (e) {
1269
1283
  console.warn(e);
@@ -1600,6 +1614,7 @@ class WebRTCPhone extends Emitter {
1600
1614
  }
1601
1615
  }
1602
1616
 
1617
+ // @Deprecated
1603
1618
  unhold(callSession , withEvent = true, isConference = false) {
1604
1619
  logger.info('WebRTC unhold', { id: callSession ? callSession.getId() : null });
1605
1620
 
@@ -0,0 +1,51 @@
1
+ import moment from 'moment';
2
+
3
+ //
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+
19
+
20
+
21
+ class Recording {
22
+
23
+
24
+
25
+
26
+
27
+
28
+ static parseMany(recordings ) {
29
+ return recordings.map(item => Recording.parse(item));
30
+ }
31
+
32
+ static parse(plain ) {
33
+ return new Recording({
34
+ deleted: plain.deleted,
35
+ fileName: plain.filename,
36
+ end: plain.end_time ? moment(plain.end_time).toDate() : null,
37
+ start: moment(plain.start_time).toDate(),
38
+ uuid: plain.uuid,
39
+ });
40
+ }
41
+
42
+ constructor({ deleted, end, fileName, start, uuid } ) {
43
+ this.deleted = deleted;
44
+ this.end = end;
45
+ this.fileName = fileName;
46
+ this.start = start;
47
+ this.uuid = uuid;
48
+ }
49
+ }
50
+
51
+ export default Recording;
@@ -1,6 +1,5 @@
1
1
  import '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
 
@@ -1,6 +1,5 @@
1
1
  import '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