@wazo/sdk 0.37.25 → 0.37.29

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 (125) hide show
  1. package/README.md +96 -58
  2. package/dist/wazo-sdk.js +3 -3
  3. package/esm/__tests__/api-client.test.js +2 -2
  4. package/esm/__tests__/web-rtc-client.test.js +10 -5
  5. package/esm/api/agentd.js +1 -1
  6. package/esm/api/amid.js +1 -1
  7. package/esm/api/application.js +1 -1
  8. package/esm/api/auth.js +1 -1
  9. package/esm/api/call-logd.js +1 -1
  10. package/esm/api/calld.js +1 -1
  11. package/esm/api/chatd.js +1 -1
  12. package/esm/api/confd.js +1 -1
  13. package/esm/api/ctid-ng.js +1 -1
  14. package/esm/api/dird.js +2 -2
  15. package/esm/api/webhookd.js +1 -1
  16. package/esm/api-client.js +2 -2
  17. package/esm/checker/Checker.js +10 -5
  18. package/esm/checker/checks/aor.js +2 -2
  19. package/esm/checker/checks/api.js +2 -2
  20. package/esm/checker/checks/index.js +10 -5
  21. package/esm/checker/checks/wazo-websocket.js +1 -1
  22. package/esm/checker/checks/webrtc-transport.js +10 -5
  23. package/esm/checker/checks/webrtc.js +10 -5
  24. package/esm/domain/AdHocAPIConference.js +2 -2
  25. package/esm/domain/CallSession.js +29 -2
  26. package/esm/domain/Contact.js +1 -1
  27. package/esm/domain/Features.js +2 -2
  28. package/esm/domain/Phone/CTIPhone.js +31 -4
  29. package/esm/domain/Phone/WebRTCPhone.js +55 -6
  30. package/esm/domain/SFUNotAvailableError.js +9 -0
  31. package/esm/domain/__tests__/CallSession.test.js +46 -2
  32. package/esm/domain/__tests__/Contact.test.js +1 -1
  33. package/esm/domain/__tests__/IndirectTransfer.test.js +29 -2
  34. package/esm/domain/__tests__/Room.test.js +29 -2
  35. package/esm/index.js +75 -10
  36. package/esm/lib/WazoSessionDescriptionHandler.js +9 -4
  37. package/esm/service/CallApi.js +2 -2
  38. package/esm/service/IssueReporter.js +1 -1
  39. package/esm/service/__tests__/IssueReporter.test.js +1 -1
  40. package/esm/service/getApiClient.js +2 -2
  41. package/esm/simple/Auth.js +74 -10
  42. package/esm/simple/Configuration.js +74 -10
  43. package/esm/simple/Directory.js +2 -2
  44. package/esm/simple/Phone.js +74 -10
  45. package/esm/simple/Websocket.js +1 -1
  46. package/esm/simple/index.js +74 -10
  47. package/esm/simple/room/LocalParticipant.js +74 -10
  48. package/esm/simple/room/Participant.js +74 -10
  49. package/esm/simple/room/RemoteParticipant.js +74 -10
  50. package/esm/simple/room/Room.js +74 -10
  51. package/esm/simple/room/SipRoom.js +74 -10
  52. package/esm/simple/room/Stream.js +74 -10
  53. package/esm/simple/room/__tests__/RemoteParticipant.test.js +74 -10
  54. package/esm/simple/utils.js +74 -10
  55. package/esm/utils/__tests__/api-requester.test.js +1 -1
  56. package/esm/utils/api-requester.js +1 -1
  57. package/esm/web-rtc-client.js +10 -5
  58. package/esm/websocket-client.js +1 -1
  59. package/lib/__tests__/api-client.test.js +2 -2
  60. package/lib/__tests__/web-rtc-client.test.js +10 -5
  61. package/lib/api/agentd.js +1 -1
  62. package/lib/api/amid.js +1 -1
  63. package/lib/api/application.js +1 -1
  64. package/lib/api/auth.js +1 -1
  65. package/lib/api/call-logd.js +1 -1
  66. package/lib/api/calld.js +1 -1
  67. package/lib/api/chatd.js +1 -1
  68. package/lib/api/confd.js +1 -1
  69. package/lib/api/ctid-ng.js +1 -1
  70. package/lib/api/dird.js +2 -2
  71. package/lib/api/webhookd.js +1 -1
  72. package/lib/api-client.js +2 -2
  73. package/lib/checker/Checker.js +10 -5
  74. package/lib/checker/checks/aor.js +2 -2
  75. package/lib/checker/checks/api.js +2 -2
  76. package/lib/checker/checks/index.js +10 -5
  77. package/lib/checker/checks/wazo-websocket.js +1 -1
  78. package/lib/checker/checks/webrtc-transport.js +10 -5
  79. package/lib/checker/checks/webrtc.js +10 -5
  80. package/lib/domain/AdHocAPIConference.js +2 -2
  81. package/lib/domain/CallSession.js +29 -2
  82. package/lib/domain/Contact.js +1 -1
  83. package/lib/domain/Features.js +2 -2
  84. package/lib/domain/Phone/CTIPhone.js +31 -4
  85. package/lib/domain/Phone/WebRTCPhone.js +55 -5
  86. package/lib/domain/SFUNotAvailableError.js +11 -0
  87. package/lib/domain/__tests__/CallSession.test.js +46 -2
  88. package/lib/domain/__tests__/Contact.test.js +1 -1
  89. package/lib/domain/__tests__/IndirectTransfer.test.js +29 -2
  90. package/lib/domain/__tests__/Room.test.js +29 -2
  91. package/lib/index.js +75 -10
  92. package/lib/lib/WazoSessionDescriptionHandler.js +9 -4
  93. package/lib/service/CallApi.js +2 -2
  94. package/lib/service/IssueReporter.js +1 -1
  95. package/lib/service/__tests__/IssueReporter.test.js +1 -1
  96. package/lib/service/getApiClient.js +2 -2
  97. package/lib/simple/Auth.js +74 -10
  98. package/lib/simple/Configuration.js +74 -10
  99. package/lib/simple/Directory.js +2 -2
  100. package/lib/simple/Phone.js +74 -10
  101. package/lib/simple/Websocket.js +1 -1
  102. package/lib/simple/index.js +74 -10
  103. package/lib/simple/room/LocalParticipant.js +74 -10
  104. package/lib/simple/room/Participant.js +74 -10
  105. package/lib/simple/room/RemoteParticipant.js +74 -10
  106. package/lib/simple/room/Room.js +74 -10
  107. package/lib/simple/room/SipRoom.js +74 -10
  108. package/lib/simple/room/Stream.js +74 -10
  109. package/lib/simple/room/__tests__/RemoteParticipant.test.js +74 -10
  110. package/lib/simple/utils.js +74 -10
  111. package/lib/utils/__tests__/api-requester.test.js +1 -1
  112. package/lib/utils/api-requester.js +1 -1
  113. package/lib/web-rtc-client.js +10 -5
  114. package/lib/websocket-client.js +1 -1
  115. package/package.json +1 -1
  116. package/src/domain/CallSession.js +32 -4
  117. package/src/domain/Contact.js +1 -1
  118. package/src/domain/Phone/WebRTCPhone.js +24 -2
  119. package/src/domain/SFUNotAvailableError.js +7 -0
  120. package/src/domain/__tests__/CallSession.test.js +17 -0
  121. package/src/index.js +2 -0
  122. package/src/lib/WazoSessionDescriptionHandler.js +8 -3
  123. package/src/simple/Phone.js +2 -1
  124. package/src/simple/index.js +2 -0
  125. package/src/utils/api-requester.js +1 -1
@@ -34,13 +34,16 @@ var updateFrom = (instance , from ) => {
34
34
 
35
35
 
36
36
 
37
+
37
38
 
38
39
 
39
40
 
40
41
 
41
42
 
43
+
42
44
 
43
45
 
46
+
44
47
 
45
48
 
46
49
 
@@ -57,6 +60,7 @@ var updateFrom = (instance , from ) => {
57
60
 
58
61
 
59
62
 
63
+
60
64
 
61
65
 
62
66
  class CallSession {
@@ -76,10 +80,14 @@ class CallSession {
76
80
 
77
81
 
78
82
 
79
-
83
+
84
+
85
+ // = creationTime
80
86
 
81
87
 
82
88
 
89
+
90
+
83
91
 
84
92
 
85
93
 
@@ -115,6 +123,8 @@ class CallSession {
115
123
 
116
124
 
117
125
 
126
+
127
+
118
128
 
119
129
  constructor({
120
130
  answered,
@@ -128,6 +138,8 @@ class CallSession {
128
138
  paused,
129
139
  ringing,
130
140
  startTime,
141
+ creationTime,
142
+ endTime,
131
143
  cameraEnabled,
132
144
  dialedExtension,
133
145
  sipCallId,
@@ -140,12 +152,16 @@ class CallSession {
140
152
  recording,
141
153
  recordingPaused,
142
154
  videoRemotelyDowngraded,
155
+ sipSession,
156
+ answerTime,
143
157
  } ) {
144
158
  this.callId = callId;
145
159
  this.sipCallId = sipCallId;
146
160
  this.displayName = displayName;
147
161
  this.number = number;
162
+ this.creationTime = creationTime;
148
163
  this.startTime = startTime;
164
+ this.endTime = endTime;
149
165
  this.isCaller = isCaller;
150
166
  this.answered = answered;
151
167
  this.answeredBySystem = answeredBySystem;
@@ -164,6 +180,8 @@ class CallSession {
164
180
  this.recording = recording || false;
165
181
  this.recordingPaused = recordingPaused || false;
166
182
  this.videoRemotelyDowngraded = videoRemotelyDowngraded;
183
+ this.sipSession = sipSession;
184
+ this.answerTime = answerTime || this.answerTime;
167
185
 
168
186
  // Useful to compare instead of instanceof with minified code
169
187
  this.type = 'CallSession';
@@ -194,7 +212,7 @@ class CallSession {
194
212
  }
195
213
 
196
214
  answer() {
197
- this.answered = true;
215
+ this.answerTime = new Date();
198
216
  }
199
217
 
200
218
  systemAnswer() {
@@ -350,6 +368,15 @@ class CallSession {
350
368
  return newFrom(callSession, CallSession);
351
369
  }
352
370
 
371
+ // Retro-compatibility: `answered` was a boolean before. We can reproduce the behaviour with a getter/setter
372
+ set answered(value ) {
373
+ this.answerTime = value ? new Date() : null;
374
+ }
375
+
376
+ get answered() {
377
+ return !!this.answerTime;
378
+ }
379
+
353
380
  static parseCall(call ) {
354
381
  return new CallSession({
355
382
  callId: call.id,
@@ -412,4 +439,21 @@ describe('CallSession domain', () => {
412
439
  expect(cs1.is(cs2)).toBeTruthy();
413
440
  expect(cs2.is(cs1)).toBeTruthy();
414
441
  });
442
+
443
+ it('should set answerTime when setting answered', () => {
444
+ const cs1 = new CallSession({});
445
+ cs1.answered = true;
446
+
447
+ const cs2 = new CallSession({});
448
+ cs2.answer();
449
+
450
+ const cs3 = new CallSession({ answered: true });
451
+
452
+ expect(cs1.answered).toBeTruthy();
453
+ expect(cs1.answerTime).not.toBeNull();
454
+ expect(cs2.answered).toBeTruthy();
455
+ expect(cs2.answerTime).not.toBeNull();
456
+ expect(cs3.answered).toBeTruthy();
457
+ expect(cs3.answerTime).not.toBeNull();
458
+ });
415
459
  });
@@ -700,7 +700,7 @@ class Contact {
700
700
  this[key] = old[key] || this[key];
701
701
  });
702
702
 
703
- if (old.lineState && !this.lineState) {
703
+ if (old.lineState) {
704
704
  this.lineState = old.lineState;
705
705
  }
706
706
 
@@ -34,13 +34,16 @@ var updateFrom = (instance , from ) => {
34
34
 
35
35
 
36
36
 
37
+
37
38
 
38
39
 
39
40
 
40
41
 
41
42
 
43
+
42
44
 
43
45
 
46
+
44
47
 
45
48
 
46
49
 
@@ -57,6 +60,7 @@ var updateFrom = (instance , from ) => {
57
60
 
58
61
 
59
62
 
63
+
60
64
 
61
65
 
62
66
  class CallSession {
@@ -76,10 +80,14 @@ class CallSession {
76
80
 
77
81
 
78
82
 
79
-
83
+
84
+
85
+ // = creationTime
80
86
 
81
87
 
82
88
 
89
+
90
+
83
91
 
84
92
 
85
93
 
@@ -115,6 +123,8 @@ class CallSession {
115
123
 
116
124
 
117
125
 
126
+
127
+
118
128
 
119
129
  constructor({
120
130
  answered,
@@ -128,6 +138,8 @@ class CallSession {
128
138
  paused,
129
139
  ringing,
130
140
  startTime,
141
+ creationTime,
142
+ endTime,
131
143
  cameraEnabled,
132
144
  dialedExtension,
133
145
  sipCallId,
@@ -140,12 +152,16 @@ class CallSession {
140
152
  recording,
141
153
  recordingPaused,
142
154
  videoRemotelyDowngraded,
155
+ sipSession,
156
+ answerTime,
143
157
  } ) {
144
158
  this.callId = callId;
145
159
  this.sipCallId = sipCallId;
146
160
  this.displayName = displayName;
147
161
  this.number = number;
162
+ this.creationTime = creationTime;
148
163
  this.startTime = startTime;
164
+ this.endTime = endTime;
149
165
  this.isCaller = isCaller;
150
166
  this.answered = answered;
151
167
  this.answeredBySystem = answeredBySystem;
@@ -164,6 +180,8 @@ class CallSession {
164
180
  this.recording = recording || false;
165
181
  this.recordingPaused = recordingPaused || false;
166
182
  this.videoRemotelyDowngraded = videoRemotelyDowngraded;
183
+ this.sipSession = sipSession;
184
+ this.answerTime = answerTime || this.answerTime;
167
185
 
168
186
  // Useful to compare instead of instanceof with minified code
169
187
  this.type = 'CallSession';
@@ -194,7 +212,7 @@ class CallSession {
194
212
  }
195
213
 
196
214
  answer() {
197
- this.answered = true;
215
+ this.answerTime = new Date();
198
216
  }
199
217
 
200
218
  systemAnswer() {
@@ -350,6 +368,15 @@ class CallSession {
350
368
  return newFrom(callSession, CallSession);
351
369
  }
352
370
 
371
+ // Retro-compatibility: `answered` was a boolean before. We can reproduce the behaviour with a getter/setter
372
+ set answered(value ) {
373
+ this.answerTime = value ? new Date() : null;
374
+ }
375
+
376
+ get answered() {
377
+ return !!this.answerTime;
378
+ }
379
+
353
380
  static parseCall(call ) {
354
381
  return new CallSession({
355
382
  callId: call.id,
@@ -34,13 +34,16 @@ var updateFrom = (instance , from ) => {
34
34
 
35
35
 
36
36
 
37
+
37
38
 
38
39
 
39
40
 
40
41
 
41
42
 
43
+
42
44
 
43
45
 
46
+
44
47
 
45
48
 
46
49
 
@@ -57,6 +60,7 @@ var updateFrom = (instance , from ) => {
57
60
 
58
61
 
59
62
 
63
+
60
64
 
61
65
 
62
66
  class CallSession {
@@ -76,10 +80,14 @@ class CallSession {
76
80
 
77
81
 
78
82
 
79
-
83
+
84
+
85
+ // = creationTime
80
86
 
81
87
 
82
88
 
89
+
90
+
83
91
 
84
92
 
85
93
 
@@ -115,6 +123,8 @@ class CallSession {
115
123
 
116
124
 
117
125
 
126
+
127
+
118
128
 
119
129
  constructor({
120
130
  answered,
@@ -128,6 +138,8 @@ class CallSession {
128
138
  paused,
129
139
  ringing,
130
140
  startTime,
141
+ creationTime,
142
+ endTime,
131
143
  cameraEnabled,
132
144
  dialedExtension,
133
145
  sipCallId,
@@ -140,12 +152,16 @@ class CallSession {
140
152
  recording,
141
153
  recordingPaused,
142
154
  videoRemotelyDowngraded,
155
+ sipSession,
156
+ answerTime,
143
157
  } ) {
144
158
  this.callId = callId;
145
159
  this.sipCallId = sipCallId;
146
160
  this.displayName = displayName;
147
161
  this.number = number;
162
+ this.creationTime = creationTime;
148
163
  this.startTime = startTime;
164
+ this.endTime = endTime;
149
165
  this.isCaller = isCaller;
150
166
  this.answered = answered;
151
167
  this.answeredBySystem = answeredBySystem;
@@ -164,6 +180,8 @@ class CallSession {
164
180
  this.recording = recording || false;
165
181
  this.recordingPaused = recordingPaused || false;
166
182
  this.videoRemotelyDowngraded = videoRemotelyDowngraded;
183
+ this.sipSession = sipSession;
184
+ this.answerTime = answerTime || this.answerTime;
167
185
 
168
186
  // Useful to compare instead of instanceof with minified code
169
187
  this.type = 'CallSession';
@@ -194,7 +212,7 @@ class CallSession {
194
212
  }
195
213
 
196
214
  answer() {
197
- this.answered = true;
215
+ this.answerTime = new Date();
198
216
  }
199
217
 
200
218
  systemAnswer() {
@@ -350,6 +368,15 @@ class CallSession {
350
368
  return newFrom(callSession, CallSession);
351
369
  }
352
370
 
371
+ // Retro-compatibility: `answered` was a boolean before. We can reproduce the behaviour with a getter/setter
372
+ set answered(value ) {
373
+ this.answerTime = value ? new Date() : null;
374
+ }
375
+
376
+ get answered() {
377
+ return !!this.answerTime;
378
+ }
379
+
353
380
  static parseCall(call ) {
354
381
  return new CallSession({
355
382
  callId: call.id,
package/lib/index.js CHANGED
@@ -475,7 +475,7 @@ const logger$c = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
475
475
 
476
476
  // Use a function here to be able to mock it in tests
477
477
  const realFetch = () => {
478
- if (typeof document !== 'undefined') {
478
+ if (typeof document !== 'undefined' && window.fetch) {
479
479
  // Browser
480
480
  return window.fetch;
481
481
  }
@@ -1935,7 +1935,7 @@ class Contact {
1935
1935
  this[key] = old[key] || this[key];
1936
1936
  });
1937
1937
 
1938
- if (old.lineState && !this.lineState) {
1938
+ if (old.lineState) {
1939
1939
  this.lineState = old.lineState;
1940
1940
  }
1941
1941
 
@@ -3260,13 +3260,16 @@ var updateFrom = (instance , from ) => {
3260
3260
 
3261
3261
 
3262
3262
 
3263
+
3263
3264
 
3264
3265
 
3265
3266
 
3266
3267
 
3267
3268
 
3269
+
3268
3270
 
3269
3271
 
3272
+
3270
3273
 
3271
3274
 
3272
3275
 
@@ -3283,6 +3286,7 @@ var updateFrom = (instance , from ) => {
3283
3286
 
3284
3287
 
3285
3288
 
3289
+
3286
3290
 
3287
3291
 
3288
3292
  class CallSession {
@@ -3302,10 +3306,14 @@ class CallSession {
3302
3306
 
3303
3307
 
3304
3308
 
3305
-
3309
+
3310
+
3311
+ // = creationTime
3306
3312
 
3307
3313
 
3308
3314
 
3315
+
3316
+
3309
3317
 
3310
3318
 
3311
3319
 
@@ -3341,6 +3349,8 @@ class CallSession {
3341
3349
 
3342
3350
 
3343
3351
 
3352
+
3353
+
3344
3354
 
3345
3355
  constructor({
3346
3356
  answered,
@@ -3354,6 +3364,8 @@ class CallSession {
3354
3364
  paused,
3355
3365
  ringing,
3356
3366
  startTime,
3367
+ creationTime,
3368
+ endTime,
3357
3369
  cameraEnabled,
3358
3370
  dialedExtension,
3359
3371
  sipCallId,
@@ -3366,12 +3378,16 @@ class CallSession {
3366
3378
  recording,
3367
3379
  recordingPaused,
3368
3380
  videoRemotelyDowngraded,
3381
+ sipSession,
3382
+ answerTime,
3369
3383
  } ) {
3370
3384
  this.callId = callId;
3371
3385
  this.sipCallId = sipCallId;
3372
3386
  this.displayName = displayName;
3373
3387
  this.number = number;
3388
+ this.creationTime = creationTime;
3374
3389
  this.startTime = startTime;
3390
+ this.endTime = endTime;
3375
3391
  this.isCaller = isCaller;
3376
3392
  this.answered = answered;
3377
3393
  this.answeredBySystem = answeredBySystem;
@@ -3390,6 +3406,8 @@ class CallSession {
3390
3406
  this.recording = recording || false;
3391
3407
  this.recordingPaused = recordingPaused || false;
3392
3408
  this.videoRemotelyDowngraded = videoRemotelyDowngraded;
3409
+ this.sipSession = sipSession;
3410
+ this.answerTime = answerTime || this.answerTime;
3393
3411
 
3394
3412
  // Useful to compare instead of instanceof with minified code
3395
3413
  this.type = 'CallSession';
@@ -3420,7 +3438,7 @@ class CallSession {
3420
3438
  }
3421
3439
 
3422
3440
  answer() {
3423
- this.answered = true;
3441
+ this.answerTime = new Date();
3424
3442
  }
3425
3443
 
3426
3444
  systemAnswer() {
@@ -3576,6 +3594,15 @@ class CallSession {
3576
3594
  return newFrom(callSession, CallSession);
3577
3595
  }
3578
3596
 
3597
+ // Retro-compatibility: `answered` was a boolean before. We can reproduce the behaviour with a getter/setter
3598
+ set answered(value ) {
3599
+ this.answerTime = value ? new Date() : null;
3600
+ }
3601
+
3602
+ get answered() {
3603
+ return !!this.answerTime;
3604
+ }
3605
+
3579
3606
  static parseCall(call ) {
3580
3607
  return new CallSession({
3581
3608
  callId: call.id,
@@ -5635,11 +5662,16 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
5635
5662
 
5636
5663
  // $FlowFixMe
5637
5664
  setRemoteSessionDescription(sessionDescription ) {
5638
- const result = super.setRemoteSessionDescription(sessionDescription);
5665
+ try {
5666
+ const result = super.setRemoteSessionDescription(sessionDescription);
5639
5667
 
5640
- this.eventEmitter.emit('setDescription', sessionDescription);
5668
+ this.eventEmitter.emit('setDescription', sessionDescription);
5641
5669
 
5642
- return result;
5670
+ return result;
5671
+ } catch (error) {
5672
+ this.logger.error('SessionDescriptionHandler.setRemoteSessionDescription error', error);
5673
+ throw error;
5674
+ }
5643
5675
  }
5644
5676
 
5645
5677
  // Overridden to avoid to fix ice-candidates missing in the SDP in react-native and chrome canary.
@@ -8787,6 +8819,14 @@ var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
8787
8819
  'default': WebSocketClient
8788
8820
  });
8789
8821
 
8822
+ /* */
8823
+ class SFUNotAvailableError extends Error {
8824
+ constructor(message = 'Sorry your user is not configured to support video conference') {
8825
+ super(message);
8826
+ this.name = 'SFUNotAvailableError';
8827
+ }
8828
+ }
8829
+
8790
8830
  var COUNTRIES = {
8791
8831
  BELGIUM: 'BE',
8792
8832
  CANADA: 'CA',
@@ -9184,6 +9224,7 @@ const ON_CAMERA_DISABLED = 'onCameraDisabled';
9184
9224
  const ON_CAMERA_RESUMED = 'onCameraResumed';
9185
9225
  const ON_CALL_CANCELED = 'onCallCanceled';
9186
9226
  const ON_CALL_FAILED = 'onCallFailed';
9227
+ const ON_CALL_REJECTED = 'onCallRejected';
9187
9228
  const ON_CALL_ENDED = 'onCallEnded';
9188
9229
  const ON_CALL_ENDING = 'onCallEnding';
9189
9230
  const ON_MESSAGE = 'onMessage';
@@ -9228,6 +9269,7 @@ const events = [
9228
9269
  ON_CAMERA_DISABLED,
9229
9270
  ON_CALL_FAILED,
9230
9271
  ON_CALL_ENDED,
9272
+ ON_CALL_REJECTED,
9231
9273
  ON_MESSAGE,
9232
9274
  ON_REINVITE,
9233
9275
  ON_TRACK,
@@ -9584,6 +9626,7 @@ class WebRTCPhone extends Emitter {
9584
9626
 
9585
9627
  // Should be called before `_onCallTerminated` or the callCount will not decrement...
9586
9628
  const callSession = this._createCallSession(sipSession);
9629
+ callSession.endTime = new Date();
9587
9630
  const wasCurrentSession = this._onCallTerminated(sipSession);
9588
9631
 
9589
9632
  return this.eventEmitter.emit(ON_CALL_ENDED, callSession, wasCurrentSession);
@@ -9779,6 +9822,7 @@ class WebRTCPhone extends Emitter {
9779
9822
  this.removeIncomingSessions(sipSessionId);
9780
9823
  }
9781
9824
 
9825
+ callSession.answerTime = new Date();
9782
9826
  this.eventEmitter.emit(ON_CALL_ACCEPTED, callSession, cameraEnabled);
9783
9827
 
9784
9828
  return callSession;
@@ -9836,6 +9880,7 @@ class WebRTCPhone extends Emitter {
9836
9880
  _onCallTerminated(sipSession ) {
9837
9881
  logger$7.info('WebRTC phone - on call terminated', { sipId: sipSession.id });
9838
9882
 
9883
+ const sipSessionId = this.getSipSessionId(sipSession);
9839
9884
  const callSession = this._createCallSession(sipSession);
9840
9885
  const isCurrentSession = this.isCurrentCallSipSession(callSession);
9841
9886
  const isCurrentIncomingCall = callSession.is(this.getIncomingCallSession());
@@ -9853,7 +9898,6 @@ class WebRTCPhone extends Emitter {
9853
9898
  }, 5);
9854
9899
  }
9855
9900
 
9856
- const sipSessionId = this.getSipSessionId(sipSession);
9857
9901
  if (sipSessionId) {
9858
9902
  this.removeIncomingSessions(sipSessionId);
9859
9903
  }
@@ -9994,6 +10038,7 @@ class WebRTCPhone extends Emitter {
9994
10038
  }
9995
10039
 
9996
10040
  this.shouldSendReinvite = false;
10041
+ callSession.answerTime = new Date();
9997
10042
  this.acceptedSessions[callSession.getId()] = true;
9998
10043
 
9999
10044
  this.eventEmitter.emit(ON_CALL_ANSWERED, callSession);
@@ -10303,6 +10348,7 @@ class WebRTCPhone extends Emitter {
10303
10348
  return Promise.resolve(null);
10304
10349
  }
10305
10350
  const callSession = this._createOutgoingCallSession(sipSession, cameraEnabled || false);
10351
+ callSession.creationTime = new Date();
10306
10352
 
10307
10353
  this.eventEmitter.emit(ON_PLAY_PROGRESS_SOUND, this.audioOutputDeviceId, this.audioOutputVolume);
10308
10354
 
@@ -10498,8 +10544,12 @@ class WebRTCPhone extends Emitter {
10498
10544
  }
10499
10545
 
10500
10546
  const sessionId = this.incomingSessions[0];
10547
+ const sipSession = this.client.getSipSession(sessionId);
10548
+ if (!sipSession) {
10549
+ return null;
10550
+ }
10501
10551
 
10502
- return this._createCallSession(this.client.getSipSession(sessionId));
10552
+ return this._createCallSession(sipSession);
10503
10553
  }
10504
10554
 
10505
10555
  sendMessage(sipSession = null, body , contentType = 'text/plain') {
@@ -10577,6 +10627,7 @@ class WebRTCPhone extends Emitter {
10577
10627
  callSession);
10578
10628
  }
10579
10629
 
10630
+ callSession.creationTime = new Date();
10580
10631
  this.eventEmitter.emit(ON_CALL_INCOMING, callSession, wantsToDoVideo);
10581
10632
  });
10582
10633
 
@@ -10616,6 +10667,13 @@ class WebRTCPhone extends Emitter {
10616
10667
  this.eventEmitter.emit(ON_CALL_ERROR, e);
10617
10668
  });
10618
10669
 
10670
+ this.client.on(this.client.REJECTED, session => {
10671
+ logger$7.info('WebRTC call rejected', session.id);
10672
+ const callSession = this._createCallSession(session);
10673
+ callSession.endTime = new Date();
10674
+ this.eventEmitter.emit(ON_CALL_REJECTED, callSession);
10675
+ });
10676
+
10619
10677
  this.client.on(this.client.UNREGISTERED, () => {
10620
10678
  logger$7.info('WebRTC unregistered');
10621
10679
  this.eventEmitter.emit(ON_UNREGISTERED);
@@ -10828,6 +10886,7 @@ class WebRTCPhone extends Emitter {
10828
10886
  const number = identity ? identity.uri._normal.user : null;
10829
10887
  const { state } = sipSession || {};
10830
10888
  const sessionId = this.getSipSessionId(sipSession);
10889
+ fromSession = fromSession || this.callSessions[sessionId];
10831
10890
 
10832
10891
  const callSession = new CallSession({
10833
10892
  callId: fromSession && fromSession.callId,
@@ -10835,6 +10894,8 @@ class WebRTCPhone extends Emitter {
10835
10894
  sipStatus: state,
10836
10895
  displayName: identity ? identity.displayName || number : number,
10837
10896
  startTime: fromSession ? fromSession.startTime : new Date(),
10897
+ creationTime: fromSession ? fromSession.creationTime : null,
10898
+ endTime: fromSession ? fromSession.endTime : null,
10838
10899
  answered: state === sessionState.SessionState.Established,
10839
10900
  paused: this.client.isCallHeld(sipSession),
10840
10901
  isCaller: 'incoming' in extra ? !extra.incoming : false,
@@ -10845,6 +10906,7 @@ class WebRTCPhone extends Emitter {
10845
10906
  videoMuted: fromSession ? fromSession.isVideoMuted() : false,
10846
10907
  recording: fromSession ? fromSession.isRecording() : false,
10847
10908
  recordingPaused: false, // @TODO
10909
+ sipSession,
10848
10910
  ...extra,
10849
10911
  });
10850
10912
 
@@ -10873,6 +10935,7 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10873
10935
  ON_CAMERA_RESUMED: ON_CAMERA_RESUMED,
10874
10936
  ON_CALL_CANCELED: ON_CALL_CANCELED,
10875
10937
  ON_CALL_FAILED: ON_CALL_FAILED,
10938
+ ON_CALL_REJECTED: ON_CALL_REJECTED,
10876
10939
  ON_CALL_ENDED: ON_CALL_ENDED,
10877
10940
  ON_CALL_ENDING: ON_CALL_ENDING,
10878
10941
  ON_MESSAGE: ON_MESSAGE,
@@ -12321,7 +12384,7 @@ class Phone extends Emitter {
12321
12384
 
12322
12385
  checkSfu() {
12323
12386
  if (!this.hasSfu()) {
12324
- throw new Error('Sorry your user is not configured to support video conference');
12387
+ throw new SFUNotAvailableError();
12325
12388
  }
12326
12389
  }
12327
12390
 
@@ -13882,6 +13945,7 @@ const Wazo = {
13882
13945
  InvalidSubscription,
13883
13946
  InvalidAuthorization,
13884
13947
  CanceledCallError,
13948
+ SFUNotAvailableError,
13885
13949
  };
13886
13950
 
13887
13951
  if (window) {
@@ -13924,6 +13988,7 @@ var index = {
13924
13988
  WazoWebSocketClient: WebSocketClient,
13925
13989
  BadResponse,
13926
13990
  ServerError,
13991
+ SFUNotAvailableError,
13927
13992
  Call,
13928
13993
  CallSession,
13929
13994
  CTIPhone,
@@ -25,7 +25,7 @@ IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
25
25
 
26
26
  // Use a function here to be able to mock it in tests
27
27
  const realFetch = () => {
28
- if (typeof document !== 'undefined') {
28
+ if (typeof document !== 'undefined' && window.fetch) {
29
29
  // Browser
30
30
  return window.fetch;
31
31
  }
@@ -497,11 +497,16 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
497
497
 
498
498
  // $FlowFixMe
499
499
  setRemoteSessionDescription(sessionDescription ) {
500
- const result = super.setRemoteSessionDescription(sessionDescription);
500
+ try {
501
+ const result = super.setRemoteSessionDescription(sessionDescription);
501
502
 
502
- this.eventEmitter.emit('setDescription', sessionDescription);
503
+ this.eventEmitter.emit('setDescription', sessionDescription);
503
504
 
504
- return result;
505
+ return result;
506
+ } catch (error) {
507
+ this.logger.error('SessionDescriptionHandler.setRemoteSessionDescription error', error);
508
+ throw error;
509
+ }
505
510
  }
506
511
 
507
512
  // Overridden to avoid to fix ice-candidates missing in the SDP in react-native and chrome canary.
@@ -1416,7 +1416,7 @@ class Contact {
1416
1416
  this[key] = old[key] || this[key];
1417
1417
  });
1418
1418
 
1419
- if (old.lineState && !this.lineState) {
1419
+ if (old.lineState) {
1420
1420
  this.lineState = old.lineState;
1421
1421
  }
1422
1422
 
@@ -2472,7 +2472,7 @@ const logger$1 = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
2472
2472
 
2473
2473
  // Use a function here to be able to mock it in tests
2474
2474
  const realFetch = () => {
2475
- if (typeof document !== 'undefined') {
2475
+ if (typeof document !== 'undefined' && window.fetch) {
2476
2476
  // Browser
2477
2477
  return window.fetch;
2478
2478
  }