@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
@@ -992,7 +992,7 @@ class Contact {
992
992
 
993
993
  return new Contact({
994
994
  sourceId: single.id || '',
995
- name: single.displayName,
995
+ name: single.displayName || '',
996
996
  number: numbers.length ? numbers[0].number : '',
997
997
  numbers,
998
998
  emails,
@@ -1023,7 +1023,7 @@ class Contact {
1023
1023
 
1024
1024
  return new Contact({
1025
1025
  sourceId: single.id || '',
1026
- name: single.name,
1026
+ name: single.name || '',
1027
1027
  number: numbers.length ? numbers[0].number : '',
1028
1028
  numbers,
1029
1029
  emails,
@@ -1124,7 +1124,7 @@ class Contact {
1124
1124
  } = {}) {
1125
1125
  this.id = id;
1126
1126
  this.uuid = uuid;
1127
- this.name = name;
1127
+ this.name = name || '';
1128
1128
  this.number = number;
1129
1129
  this.numbers = numbers;
1130
1130
  this.email = email;
@@ -2008,7 +2008,7 @@ class CallSession {
2008
2008
  return newFrom(callSession, CallSession);
2009
2009
  }
2010
2010
 
2011
- static parseCall(session , call ) {
2011
+ static parseCall(call ) {
2012
2012
  return new CallSession({
2013
2013
  callId: call.id,
2014
2014
  sipCallId: call.sipCallId,
@@ -2061,17 +2061,66 @@ class Emitter {
2061
2061
 
2062
2062
  //
2063
2063
 
2064
+
2065
+
2066
+
2067
+
2068
+
2069
+
2070
+
2071
+
2072
+
2073
+
2074
+
2075
+
2076
+
2077
+
2078
+
2079
+
2080
+ class Recording {
2081
+
2082
+
2083
+
2084
+
2085
+
2086
+
2087
+ static parseMany(recordings ) {
2088
+ return recordings.map(item => Recording.parse(item));
2089
+ }
2090
+
2091
+ static parse(plain ) {
2092
+ return new Recording({
2093
+ deleted: plain.deleted,
2094
+ fileName: plain.filename,
2095
+ end: plain.end_time ? moment__default['default'](plain.end_time).toDate() : null,
2096
+ start: moment__default['default'](plain.start_time).toDate(),
2097
+ uuid: plain.uuid,
2098
+ });
2099
+ }
2100
+
2101
+ constructor({ deleted, end, fileName, start, uuid } ) {
2102
+ this.deleted = deleted;
2103
+ this.end = end;
2104
+ this.fileName = fileName;
2105
+ this.start = start;
2106
+ this.uuid = uuid;
2107
+ }
2108
+ }
2109
+
2110
+ //
2111
+
2064
2112
 
2065
-
2113
+
2066
2114
 
2067
2115
 
2068
2116
 
2069
2117
 
2070
2118
 
2071
-
2119
+
2072
2120
 
2073
2121
 
2074
2122
 
2123
+
2075
2124
 
2076
2125
 
2077
2126
 
@@ -2084,7 +2133,7 @@ class Emitter {
2084
2133
 
2085
2134
 
2086
2135
 
2087
-
2136
+
2088
2137
 
2089
2138
 
2090
2139
 
@@ -2099,13 +2148,14 @@ class Emitter {
2099
2148
 
2100
2149
 
2101
2150
 
2102
-
2151
+
2152
+
2103
2153
 
2104
2154
 
2105
2155
  class CallLog {
2106
2156
 
2107
2157
 
2108
-
2158
+
2109
2159
 
2110
2160
 
2111
2161
 
@@ -2122,7 +2172,7 @@ class CallLog {
2122
2172
 
2123
2173
 
2124
2174
 
2125
-
2175
+
2126
2176
 
2127
2177
  static merge(current , toMerge ) {
2128
2178
  const onlyUnique = (value, index, self) => self.indexOf(value) === index;
@@ -2139,7 +2189,7 @@ class CallLog {
2139
2189
 
2140
2190
  static parse(plain ) {
2141
2191
  return new CallLog({
2142
- answer: moment__default['default'](plain.answer).toDate(),
2192
+ answer: plain.answer ? moment__default['default'](plain.answer).toDate() : null,
2143
2193
  answered: plain.answered,
2144
2194
  callDirection: plain.call_direction,
2145
2195
  destination: {
@@ -2153,13 +2203,14 @@ class CallLog {
2153
2203
  id: plain.id,
2154
2204
  duration: (plain.duration || 0) * 1000, // duration is in seconds
2155
2205
  start: moment__default['default'](plain.start).toDate(),
2156
- end: moment__default['default'](plain.end).toDate(),
2206
+ end: plain.end ? moment__default['default'](plain.end).toDate() : null,
2207
+ recordings: Recording.parseMany(plain.recordings),
2157
2208
  });
2158
2209
  }
2159
2210
 
2160
2211
  static parseNew(plain , session ) {
2161
2212
  return new CallLog({
2162
- answer: moment__default['default'](plain.answer).toDate(),
2213
+ answer: plain.answer ? moment__default['default'](plain.answer).toDate() : null,
2163
2214
  answered: plain.answered,
2164
2215
  callDirection: plain.call_direction,
2165
2216
  destination: {
@@ -2173,7 +2224,8 @@ class CallLog {
2173
2224
  id: plain.id,
2174
2225
  duration: (plain.duration || 0) * 1000, // duration is in seconds
2175
2226
  start: moment__default['default'](plain.start).toDate(),
2176
- end: moment__default['default'](plain.end).toDate(),
2227
+ end: plain.end ? moment__default['default'](plain.end).toDate() : null,
2228
+ recordings: Recording.parseMany(plain.recordings),
2177
2229
  // @TODO: FIXME add verification declined vs missed call
2178
2230
  newMissedCall: session
2179
2231
  && session.hasExtension(plain.requested_extension || plain.destination_extension) && !plain.answered,
@@ -2633,7 +2685,13 @@ class IssueReporter {
2633
2685
  }
2634
2686
 
2635
2687
  _isLevelAbove(level1 , level2 ) {
2636
- return LOG_LEVELS.indexOf(level1) > LOG_LEVELS.indexOf(level2);
2688
+ const index1 = LOG_LEVELS.indexOf(level1);
2689
+ const index2 = LOG_LEVELS.indexOf(level2);
2690
+ if (index1 === -1 || index2 === -1) {
2691
+ return false;
2692
+ }
2693
+
2694
+ return index1 > index2;
2637
2695
  }
2638
2696
 
2639
2697
  _makeCategory(category ) {
@@ -2691,6 +2749,7 @@ class ApiRequester {
2691
2749
 
2692
2750
 
2693
2751
 
2752
+
2694
2753
 
2695
2754
 
2696
2755
 
@@ -2730,6 +2789,8 @@ class ApiRequester {
2730
2789
  this.token = token;
2731
2790
  }
2732
2791
 
2792
+ this.shouldLogErrors = true;
2793
+
2733
2794
  methods.forEach(method => {
2734
2795
  // $FlowFixMe
2735
2796
  ApiRequester.prototype[method] = function sugar(...args) {
@@ -2753,6 +2814,14 @@ class ApiRequester {
2753
2814
  this.fetchOptions = options;
2754
2815
  }
2755
2816
 
2817
+ disableErrorLogging() {
2818
+ this.shouldLogErrors = false;
2819
+ }
2820
+
2821
+ enableErrorLogging() {
2822
+ this.shouldLogErrors = true;
2823
+ }
2824
+
2756
2825
  async call(
2757
2826
  path ,
2758
2827
  method = 'get',
@@ -2813,7 +2882,9 @@ class ApiRequester {
2813
2882
  ? exceptionClass.fromText(err, response.status)
2814
2883
  : exceptionClass.fromResponse(err, response.status);
2815
2884
 
2816
- logger$2.error('API error', error);
2885
+ if (this.shouldLogErrors) {
2886
+ logger$2.error('API error', error);
2887
+ }
2817
2888
 
2818
2889
  throw error;
2819
2890
  });
@@ -2821,7 +2892,9 @@ class ApiRequester {
2821
2892
 
2822
2893
  return newParse(response, isJson);
2823
2894
  }).catch(error => {
2824
- logger$2.error('Fetch failed', { url, options, message: error.message, stack: error.stack });
2895
+ if (this.shouldLogErrors) {
2896
+ logger$2.error('Fetch failed', { url, options, message: error.message, stack: error.stack });
2897
+ }
2825
2898
 
2826
2899
  throw error;
2827
2900
  });
@@ -4681,6 +4754,10 @@ class ApiClient {
4681
4754
  this.fetchOptions = fetchOptions;
4682
4755
  this.client.setFetchOptions(fetchOptions);
4683
4756
  }
4757
+
4758
+ disableErrorLogging() {
4759
+ this.client.disableErrorLogging();
4760
+ }
4684
4761
  }
4685
4762
 
4686
4763
  /* eslint-disable dot-notation */
@@ -4913,7 +4990,7 @@ class CTIPhone extends Emitter {
4913
4990
  if (!this.currentCall) {
4914
4991
  return null;
4915
4992
  }
4916
- const callSession = CallSession.parseCall(this.session, this.currentCall);
4993
+ const callSession = CallSession.parseCall(this.currentCall);
4917
4994
  this.eventEmitter.emit('onCallOutgoing', callSession);
4918
4995
 
4919
4996
  return callSession;
@@ -5097,6 +5174,10 @@ class CTIPhone extends Emitter {
5097
5174
  return null;
5098
5175
  }
5099
5176
 
5177
+ getLocalVideoStream() {
5178
+ return null;
5179
+ }
5180
+
5100
5181
  setActiveSipSession() {}
5101
5182
 
5102
5183
  isRegistered() {
@@ -5112,7 +5193,7 @@ class CTIPhone extends Emitter {
5112
5193
  }
5113
5194
 
5114
5195
  getCurrentCallSession() {
5115
- return this.currentCall ? CallSession.parseCall(this.session, this.currentCall) : null;
5196
+ return this.currentCall ? CallSession.parseCall(this.currentCall) : null;
5116
5197
  }
5117
5198
 
5118
5199
  enableRinging() {}
@@ -2,20 +2,4 @@
2
2
 
3
3
  require('sip.js/lib/api/session-state');
4
4
  require('moment');
5
- var jsrsasign = require('jsrsasign');
6
5
 
7
- //
8
-
9
- const swarmPublicKey = `-----BEGIN PUBLIC KEY-----
10
- MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmkXOuNfY8u5xoTiIhkb8
11
- djnbIwG/Wrz3vpo8BZir8L5e1a1nSy740qBjP7ZINBQoALDhFfmdOfJnCyEGiHuz
12
- ZW6jbG6C3PryE3Bu6GKwqSmD6k3q4Zk27fpwYAnNl+rWhYYM563rJZBda/INyHNN
13
- pK7M1mixWi7gNdjjXwoEXSSBx+VpYMkY6LiAB2mvHXTY9M1qI14dvgGoQISZQoKi
14
- NMTRCg5UP2ic0Dd9nSz/XpcOxGfa+0fwIl1F7RC1tJXOqvkGGPTOV4LLfg/Yta3h
15
- nUPX9EZZDIX6vO/0IBV1LzjSl2A1bYFYAjJfowv3i1CpvONBOClHjSY5t9Y8MH6p
16
- BwIDAQAB
17
- -----END PUBLIC KEY-----`;
18
-
19
- //
20
-
21
- jsrsasign.KEYUTIL.getKey(swarmPublicKey);
@@ -5,10 +5,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var invitation = require('sip.js/lib/api/invitation');
6
6
  var sessionState = require('sip.js/lib/api/session-state');
7
7
  var moment = require('moment');
8
- var jsrsasign = require('jsrsasign');
9
8
  require('webrtc-adapter');
10
9
  require('sip.js/lib/api/user-agent-state');
11
- require('sip.js/lib/api/message');
12
10
  require('sip.js/lib/core/messages/parser');
13
11
  require('sip.js/lib/core/messages/methods/constants');
14
12
  require('sip.js/lib/grammar/uri');
@@ -26,6 +24,7 @@ require('sip.js/lib/platform/web/session-description-handler/session-description
26
24
  require('sip.js/lib/platform/web/session-description-handler/session-description-handler-options');
27
25
  require('js-base64');
28
26
  require('sdp-transform');
27
+ var jsrsasign = require('jsrsasign');
29
28
  require('json-to-graphql-query/lib/jsonToGraphQLQuery');
30
29
 
31
30
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
@@ -44,22 +43,6 @@ var newFrom = (instance , ToClass ) => {
44
43
  return new ToClass(args);
45
44
  };
46
45
 
47
- //
48
-
49
- const swarmPublicKey = `-----BEGIN PUBLIC KEY-----
50
- MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmkXOuNfY8u5xoTiIhkb8
51
- djnbIwG/Wrz3vpo8BZir8L5e1a1nSy740qBjP7ZINBQoALDhFfmdOfJnCyEGiHuz
52
- ZW6jbG6C3PryE3Bu6GKwqSmD6k3q4Zk27fpwYAnNl+rWhYYM563rJZBda/INyHNN
53
- pK7M1mixWi7gNdjjXwoEXSSBx+VpYMkY6LiAB2mvHXTY9M1qI14dvgGoQISZQoKi
54
- NMTRCg5UP2ic0Dd9nSz/XpcOxGfa+0fwIl1F7RC1tJXOqvkGGPTOV4LLfg/Yta3h
55
- nUPX9EZZDIX6vO/0IBV1LzjSl2A1bYFYAjJfowv3i1CpvONBOClHjSY5t9Y8MH6p
56
- BwIDAQAB
57
- -----END PUBLIC KEY-----`;
58
-
59
- //
60
-
61
- jsrsasign.KEYUTIL.getKey(swarmPublicKey);
62
-
63
46
  //
64
47
  /* eslint-disable no-param-reassign */
65
48
 
@@ -383,7 +366,7 @@ class CallSession {
383
366
  return newFrom(callSession, CallSession);
384
367
  }
385
368
 
386
- static parseCall(session , call ) {
369
+ static parseCall(call ) {
387
370
  return new CallSession({
388
371
  callId: call.id,
389
372
  sipCallId: call.sipCallId,
@@ -679,7 +662,13 @@ class IssueReporter {
679
662
  }
680
663
 
681
664
  _isLevelAbove(level1 , level2 ) {
682
- return LOG_LEVELS.indexOf(level1) > LOG_LEVELS.indexOf(level2);
665
+ const index1 = LOG_LEVELS.indexOf(level1);
666
+ const index2 = LOG_LEVELS.indexOf(level2);
667
+ if (index1 === -1 || index2 === -1) {
668
+ return false;
669
+ }
670
+
671
+ return index1 > index2;
683
672
  }
684
673
 
685
674
  _makeCategory(category ) {
@@ -738,6 +727,22 @@ class Emitter {
738
727
  }
739
728
  }
740
729
 
730
+ //
731
+
732
+ const swarmPublicKey = `-----BEGIN PUBLIC KEY-----
733
+ MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmkXOuNfY8u5xoTiIhkb8
734
+ djnbIwG/Wrz3vpo8BZir8L5e1a1nSy740qBjP7ZINBQoALDhFfmdOfJnCyEGiHuz
735
+ ZW6jbG6C3PryE3Bu6GKwqSmD6k3q4Zk27fpwYAnNl+rWhYYM563rJZBda/INyHNN
736
+ pK7M1mixWi7gNdjjXwoEXSSBx+VpYMkY6LiAB2mvHXTY9M1qI14dvgGoQISZQoKi
737
+ NMTRCg5UP2ic0Dd9nSz/XpcOxGfa+0fwIl1F7RC1tJXOqvkGGPTOV4LLfg/Yta3h
738
+ nUPX9EZZDIX6vO/0IBV1LzjSl2A1bYFYAjJfowv3i1CpvONBOClHjSY5t9Y8MH6p
739
+ BwIDAQAB
740
+ -----END PUBLIC KEY-----`;
741
+
742
+ //
743
+
744
+ jsrsasign.KEYUTIL.getKey(swarmPublicKey);
745
+
741
746
  /* eslint-disable dot-notation */
742
747
 
743
748
  // Can't use node cache mechanism here because when requiring lib/CallApi.js
@@ -945,9 +950,14 @@ class WebRTCPhone extends Emitter {
945
950
  return true;
946
951
  }
947
952
 
948
- async sendReinvite(callSession , constraints = null, conference = false) {
953
+ async sendReinvite(callSession , constraints = null, conference = false,
954
+ audioOnly = false) {
949
955
  const sipSession = this.findSipSession(callSession);
950
- logger.info('WebRTC phone - send reinvite', { sessionId: sipSession ? sipSession.id : null, constraints });
956
+ logger.info('WebRTC phone - send reinvite', {
957
+ sessionId: sipSession ? sipSession.id : null,
958
+ constraints,
959
+ audioOnly,
960
+ });
951
961
 
952
962
  if (!sipSession) {
953
963
  return null;
@@ -973,7 +983,7 @@ class WebRTCPhone extends Emitter {
973
983
  // Force reinvite in SDH
974
984
  sipSession.sessionDescriptionHandler.localMediaStreamConstraints = null;
975
985
 
976
- return this.client.reinvite(sipSession, constraints, conference);
986
+ return this.client.reinvite(sipSession, constraints, conference, audioOnly);
977
987
  }
978
988
 
979
989
  getUserAgent() {
@@ -1049,9 +1059,9 @@ class WebRTCPhone extends Emitter {
1049
1059
  }
1050
1060
 
1051
1061
  // Release local video stream when downgrading to audio
1052
- const localVideoStream = sipSession.sessionDescriptionHandler.localMediaStream;
1062
+ const localStream = sipSession.sessionDescriptionHandler.localMediaStream;
1053
1063
  const pc = sipSession.sessionDescriptionHandler.peerConnection;
1054
- const videoTracks = localVideoStream.getVideoTracks();
1064
+ const videoTracks = localStream.getVideoTracks();
1055
1065
 
1056
1066
  // Remove video senders
1057
1067
  pc.getSenders().filter(sender => sender.track && sender.track.kind === 'video').forEach(videoSender => {
@@ -1066,7 +1076,7 @@ class WebRTCPhone extends Emitter {
1066
1076
  videoTracks.forEach(videoTrack => {
1067
1077
  videoTrack.enabled = false;
1068
1078
  videoTrack.stop();
1069
- localVideoStream.removeTrack(videoTrack);
1079
+ localStream.removeTrack(videoTrack);
1070
1080
  });
1071
1081
 
1072
1082
  this._sendReinviteMessage(callSession, false);
@@ -1083,12 +1093,14 @@ class WebRTCPhone extends Emitter {
1083
1093
 
1084
1094
  const pc = sipSession.sessionDescriptionHandler.peerConnection;
1085
1095
  const shouldScreenShare = constraints && constraints.screen;
1096
+ const options = sipSession.sessionDescriptionHandlerOptionsReInvite;
1097
+ const wasAudioOnly = options && options.audioOnly;
1086
1098
 
1087
1099
  // Check if a video sender already exists
1088
1100
  let videoSender;
1089
1101
  if (isConference) {
1090
1102
  const trans = pc.getTransceivers().find(transceiver => transceiver.mid === '1');
1091
- videoSender = trans.sender;
1103
+ videoSender = trans ? trans.sender : null;
1092
1104
  } else {
1093
1105
  videoSender = pc.getSenders().find(sender => sender.track === null);
1094
1106
  }
@@ -1125,6 +1137,11 @@ class WebRTCPhone extends Emitter {
1125
1137
  this._onScreenSharing(newStream, sipSession, callSession, false);
1126
1138
  }
1127
1139
 
1140
+ // We have to reinvite to change the direction on the bundle when upgrading from an audioOnly conference
1141
+ if (isConference && wasAudioOnly) {
1142
+ return true;
1143
+ }
1144
+
1128
1145
  // No reinvite needed here
1129
1146
  return false;
1130
1147
  }
@@ -1209,7 +1226,7 @@ class WebRTCPhone extends Emitter {
1209
1226
  event.track.enabled = false;
1210
1227
  }
1211
1228
 
1212
- return this.eventEmitter.emit(ON_VIDEO_STREAM, stream, event.track.id, event);
1229
+ return this.eventEmitter.emit(ON_VIDEO_STREAM, stream, event.track.id, event, sipSession);
1213
1230
  };
1214
1231
 
1215
1232
  peerConnection.onremovestream = event => {
@@ -1265,14 +1282,11 @@ class WebRTCPhone extends Emitter {
1265
1282
  const targetCallSession = callSession || this.currentCallSession;
1266
1283
  const conference = this.isConference(targetCallSession);
1267
1284
 
1268
- if (this.currentScreenShare.sender && this.currentScreenShare.hadVideo) {
1269
- // When stopping screenshare and we had video before that, we have to re-upgrade
1270
- await this.sendReinvite(targetCallSession, { audio: false, video: true }, conference);
1271
- } else {
1272
- // When upgrading directly to screenshare (eg: we don't have a videoLocalStream to replace)
1273
- // We have to downgrade to audio.
1274
- await this.sendReinvite(targetCallSession, { audio: false, video: false }, conference);
1275
- }
1285
+ // When stopping screenshare and we had video before that, we have to re-upgrade
1286
+ // When upgrading directly to screenshare (eg: we don't have a videoLocalStream to replace)
1287
+ // We have to downgrade to audio.
1288
+ const screenshareStopped = this.currentScreenShare.sender && this.currentScreenShare.hadVideo;
1289
+ await this.sendReinvite(targetCallSession, { audio: false, video: screenshareStopped }, conference);
1276
1290
  }
1277
1291
  } catch (e) {
1278
1292
  console.warn(e);
@@ -1609,6 +1623,7 @@ class WebRTCPhone extends Emitter {
1609
1623
  }
1610
1624
  }
1611
1625
 
1626
+ // @Deprecated
1612
1627
  unhold(callSession , withEvent = true, isConference = false) {
1613
1628
  logger.info('WebRTC unhold', { id: callSession ? callSession.getId() : null });
1614
1629
 
@@ -0,0 +1,57 @@
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
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+
19
+
20
+
21
+
22
+
23
+
24
+
25
+
26
+
27
+ class Recording {
28
+
29
+
30
+
31
+
32
+
33
+
34
+ static parseMany(recordings ) {
35
+ return recordings.map(item => Recording.parse(item));
36
+ }
37
+
38
+ static parse(plain ) {
39
+ return new Recording({
40
+ deleted: plain.deleted,
41
+ fileName: plain.filename,
42
+ end: plain.end_time ? moment__default['default'](plain.end_time).toDate() : null,
43
+ start: moment__default['default'](plain.start_time).toDate(),
44
+ uuid: plain.uuid,
45
+ });
46
+ }
47
+
48
+ constructor({ deleted, end, fileName, start, uuid } ) {
49
+ this.deleted = deleted;
50
+ this.end = end;
51
+ this.fileName = fileName;
52
+ this.start = start;
53
+ this.uuid = uuid;
54
+ }
55
+ }
56
+
57
+ module.exports = Recording;
@@ -2,7 +2,6 @@
2
2
 
3
3
  require('sip.js/lib/api/session-state');
4
4
  require('moment');
5
- var jsrsasign = require('jsrsasign');
6
5
 
7
6
  //
8
7
 
@@ -15,22 +14,6 @@ var newFrom = (instance , ToClass ) => {
15
14
  return new ToClass(args);
16
15
  };
17
16
 
18
- //
19
-
20
- const swarmPublicKey = `-----BEGIN PUBLIC KEY-----
21
- MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmkXOuNfY8u5xoTiIhkb8
22
- djnbIwG/Wrz3vpo8BZir8L5e1a1nSy740qBjP7ZINBQoALDhFfmdOfJnCyEGiHuz
23
- ZW6jbG6C3PryE3Bu6GKwqSmD6k3q4Zk27fpwYAnNl+rWhYYM563rJZBda/INyHNN
24
- pK7M1mixWi7gNdjjXwoEXSSBx+VpYMkY6LiAB2mvHXTY9M1qI14dvgGoQISZQoKi
25
- NMTRCg5UP2ic0Dd9nSz/XpcOxGfa+0fwIl1F7RC1tJXOqvkGGPTOV4LLfg/Yta3h
26
- nUPX9EZZDIX6vO/0IBV1LzjSl2A1bYFYAjJfowv3i1CpvONBOClHjSY5t9Y8MH6p
27
- BwIDAQAB
28
- -----END PUBLIC KEY-----`;
29
-
30
- //
31
-
32
- jsrsasign.KEYUTIL.getKey(swarmPublicKey);
33
-
34
17
  //
35
18
  /* eslint-disable no-param-reassign */
36
19
 
@@ -2,7 +2,6 @@
2
2
 
3
3
  require('sip.js/lib/api/session-state');
4
4
  require('moment');
5
- var jsrsasign = require('jsrsasign');
6
5
 
7
6
  //
8
7
 
@@ -15,22 +14,6 @@ var newFrom = (instance , ToClass ) => {
15
14
  return new ToClass(args);
16
15
  };
17
16
 
18
- //
19
-
20
- const swarmPublicKey = `-----BEGIN PUBLIC KEY-----
21
- MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmkXOuNfY8u5xoTiIhkb8
22
- djnbIwG/Wrz3vpo8BZir8L5e1a1nSy740qBjP7ZINBQoALDhFfmdOfJnCyEGiHuz
23
- ZW6jbG6C3PryE3Bu6GKwqSmD6k3q4Zk27fpwYAnNl+rWhYYM563rJZBda/INyHNN
24
- pK7M1mixWi7gNdjjXwoEXSSBx+VpYMkY6LiAB2mvHXTY9M1qI14dvgGoQISZQoKi
25
- NMTRCg5UP2ic0Dd9nSz/XpcOxGfa+0fwIl1F7RC1tJXOqvkGGPTOV4LLfg/Yta3h
26
- nUPX9EZZDIX6vO/0IBV1LzjSl2A1bYFYAjJfowv3i1CpvONBOClHjSY5t9Y8MH6p
27
- BwIDAQAB
28
- -----END PUBLIC KEY-----`;
29
-
30
- //
31
-
32
- jsrsasign.KEYUTIL.getKey(swarmPublicKey);
33
-
34
17
  //
35
18
  /* eslint-disable no-param-reassign */
36
19