@wazo/sdk 0.37.27 → 0.37.28

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 (49) hide show
  1. package/README.md +1 -1
  2. package/dist/wazo-sdk.js +2 -2
  3. package/esm/domain/CallSession.js +15 -0
  4. package/esm/domain/Phone/CTIPhone.js +15 -0
  5. package/esm/domain/Phone/WebRTCPhone.js +32 -1
  6. package/esm/domain/SFUNotAvailableError.js +9 -0
  7. package/esm/domain/__tests__/CallSession.test.js +15 -0
  8. package/esm/domain/__tests__/IndirectTransfer.test.js +15 -0
  9. package/esm/domain/__tests__/Room.test.js +15 -0
  10. package/esm/index.js +43 -1
  11. package/esm/simple/Auth.js +42 -1
  12. package/esm/simple/Configuration.js +42 -1
  13. package/esm/simple/Phone.js +42 -1
  14. package/esm/simple/index.js +42 -1
  15. package/esm/simple/room/LocalParticipant.js +42 -1
  16. package/esm/simple/room/Participant.js +42 -1
  17. package/esm/simple/room/RemoteParticipant.js +42 -1
  18. package/esm/simple/room/Room.js +42 -1
  19. package/esm/simple/room/SipRoom.js +42 -1
  20. package/esm/simple/room/Stream.js +42 -1
  21. package/esm/simple/room/__tests__/RemoteParticipant.test.js +42 -1
  22. package/esm/simple/utils.js +42 -1
  23. package/lib/domain/CallSession.js +15 -0
  24. package/lib/domain/Phone/CTIPhone.js +15 -0
  25. package/lib/domain/Phone/WebRTCPhone.js +32 -0
  26. package/lib/domain/SFUNotAvailableError.js +11 -0
  27. package/lib/domain/__tests__/CallSession.test.js +15 -0
  28. package/lib/domain/__tests__/IndirectTransfer.test.js +15 -0
  29. package/lib/domain/__tests__/Room.test.js +15 -0
  30. package/lib/index.js +43 -1
  31. package/lib/simple/Auth.js +42 -1
  32. package/lib/simple/Configuration.js +42 -1
  33. package/lib/simple/Phone.js +42 -1
  34. package/lib/simple/index.js +42 -1
  35. package/lib/simple/room/LocalParticipant.js +42 -1
  36. package/lib/simple/room/Participant.js +42 -1
  37. package/lib/simple/room/RemoteParticipant.js +42 -1
  38. package/lib/simple/room/Room.js +42 -1
  39. package/lib/simple/room/SipRoom.js +42 -1
  40. package/lib/simple/room/Stream.js +42 -1
  41. package/lib/simple/room/__tests__/RemoteParticipant.test.js +42 -1
  42. package/lib/simple/utils.js +42 -1
  43. package/package.json +1 -1
  44. package/src/domain/CallSession.js +16 -0
  45. package/src/domain/Phone/WebRTCPhone.js +16 -0
  46. package/src/domain/SFUNotAvailableError.js +7 -0
  47. package/src/index.js +2 -0
  48. package/src/simple/Phone.js +2 -1
  49. package/src/simple/index.js +2 -0
@@ -3265,8 +3265,10 @@ var updateFrom = (instance , from ) => {
3265
3265
 
3266
3266
 
3267
3267
 
3268
+
3268
3269
 
3269
3270
 
3271
+
3270
3272
 
3271
3273
 
3272
3274
 
@@ -3283,6 +3285,7 @@ var updateFrom = (instance , from ) => {
3283
3285
 
3284
3286
 
3285
3287
 
3288
+
3286
3289
 
3287
3290
 
3288
3291
  class CallSession {
@@ -3302,8 +3305,12 @@ class CallSession {
3302
3305
 
3303
3306
 
3304
3307
 
3308
+
3309
+
3305
3310
 
3306
3311
 
3312
+
3313
+
3307
3314
 
3308
3315
 
3309
3316
 
@@ -3341,6 +3348,8 @@ class CallSession {
3341
3348
 
3342
3349
 
3343
3350
 
3351
+
3352
+
3344
3353
 
3345
3354
  constructor({
3346
3355
  answered,
@@ -3354,6 +3363,8 @@ class CallSession {
3354
3363
  paused,
3355
3364
  ringing,
3356
3365
  startTime,
3366
+ creationTime,
3367
+ endTime,
3357
3368
  cameraEnabled,
3358
3369
  dialedExtension,
3359
3370
  sipCallId,
@@ -3366,12 +3377,15 @@ class CallSession {
3366
3377
  recording,
3367
3378
  recordingPaused,
3368
3379
  videoRemotelyDowngraded,
3380
+ sipSession,
3369
3381
  } ) {
3370
3382
  this.callId = callId;
3371
3383
  this.sipCallId = sipCallId;
3372
3384
  this.displayName = displayName;
3373
3385
  this.number = number;
3386
+ this.creationTime = creationTime;
3374
3387
  this.startTime = startTime;
3388
+ this.endTime = endTime;
3375
3389
  this.isCaller = isCaller;
3376
3390
  this.answered = answered;
3377
3391
  this.answeredBySystem = answeredBySystem;
@@ -3390,6 +3404,7 @@ class CallSession {
3390
3404
  this.recording = recording || false;
3391
3405
  this.recordingPaused = recordingPaused || false;
3392
3406
  this.videoRemotelyDowngraded = videoRemotelyDowngraded;
3407
+ this.sipSession = sipSession;
3393
3408
 
3394
3409
  // Useful to compare instead of instanceof with minified code
3395
3410
  this.type = 'CallSession';
@@ -8735,6 +8750,7 @@ const ON_CAMERA_DISABLED = 'onCameraDisabled';
8735
8750
  const ON_CAMERA_RESUMED = 'onCameraResumed';
8736
8751
  const ON_CALL_CANCELED = 'onCallCanceled';
8737
8752
  const ON_CALL_FAILED = 'onCallFailed';
8753
+ const ON_CALL_REJECTED = 'onCallRejected';
8738
8754
  const ON_CALL_ENDED = 'onCallEnded';
8739
8755
  const ON_CALL_ENDING = 'onCallEnding';
8740
8756
  const ON_MESSAGE = 'onMessage';
@@ -8779,6 +8795,7 @@ const events = [
8779
8795
  ON_CAMERA_DISABLED,
8780
8796
  ON_CALL_FAILED,
8781
8797
  ON_CALL_ENDED,
8798
+ ON_CALL_REJECTED,
8782
8799
  ON_MESSAGE,
8783
8800
  ON_REINVITE,
8784
8801
  ON_TRACK,
@@ -9135,6 +9152,7 @@ class WebRTCPhone extends Emitter {
9135
9152
 
9136
9153
  // Should be called before `_onCallTerminated` or the callCount will not decrement...
9137
9154
  const callSession = this._createCallSession(sipSession);
9155
+ callSession.endTime = new Date();
9138
9156
  const wasCurrentSession = this._onCallTerminated(sipSession);
9139
9157
 
9140
9158
  return this.eventEmitter.emit(ON_CALL_ENDED, callSession, wasCurrentSession);
@@ -9854,6 +9872,7 @@ class WebRTCPhone extends Emitter {
9854
9872
  return Promise.resolve(null);
9855
9873
  }
9856
9874
  const callSession = this._createOutgoingCallSession(sipSession, cameraEnabled || false);
9875
+ callSession.creationTime = new Date();
9857
9876
 
9858
9877
  this.eventEmitter.emit(ON_PLAY_PROGRESS_SOUND, this.audioOutputDeviceId, this.audioOutputVolume);
9859
9878
 
@@ -10132,6 +10151,7 @@ class WebRTCPhone extends Emitter {
10132
10151
  callSession);
10133
10152
  }
10134
10153
 
10154
+ callSession.creationTime = new Date();
10135
10155
  this.eventEmitter.emit(ON_CALL_INCOMING, callSession, wantsToDoVideo);
10136
10156
  });
10137
10157
 
@@ -10171,6 +10191,13 @@ class WebRTCPhone extends Emitter {
10171
10191
  this.eventEmitter.emit(ON_CALL_ERROR, e);
10172
10192
  });
10173
10193
 
10194
+ this.client.on(this.client.REJECTED, session => {
10195
+ logger$7.info('WebRTC call rejected', session.id);
10196
+ const callSession = this._createCallSession(session);
10197
+ callSession.endTime = new Date();
10198
+ this.eventEmitter.emit(ON_CALL_REJECTED, callSession);
10199
+ });
10200
+
10174
10201
  this.client.on(this.client.UNREGISTERED, () => {
10175
10202
  logger$7.info('WebRTC unregistered');
10176
10203
  this.eventEmitter.emit(ON_UNREGISTERED);
@@ -10383,6 +10410,7 @@ class WebRTCPhone extends Emitter {
10383
10410
  const number = identity ? identity.uri._normal.user : null;
10384
10411
  const { state } = sipSession || {};
10385
10412
  const sessionId = this.getSipSessionId(sipSession);
10413
+ fromSession = fromSession || this.callSessions[sessionId];
10386
10414
 
10387
10415
  const callSession = new CallSession({
10388
10416
  callId: fromSession && fromSession.callId,
@@ -10390,6 +10418,8 @@ class WebRTCPhone extends Emitter {
10390
10418
  sipStatus: state,
10391
10419
  displayName: identity ? identity.displayName || number : number,
10392
10420
  startTime: fromSession ? fromSession.startTime : new Date(),
10421
+ creationTime: fromSession ? fromSession.creationTime : null,
10422
+ endTime: fromSession ? fromSession.endTime : null,
10393
10423
  answered: state === sessionState.SessionState.Established,
10394
10424
  paused: this.client.isCallHeld(sipSession),
10395
10425
  isCaller: 'incoming' in extra ? !extra.incoming : false,
@@ -10400,6 +10430,7 @@ class WebRTCPhone extends Emitter {
10400
10430
  videoMuted: fromSession ? fromSession.isVideoMuted() : false,
10401
10431
  recording: fromSession ? fromSession.isRecording() : false,
10402
10432
  recordingPaused: false, // @TODO
10433
+ sipSession,
10403
10434
  ...extra,
10404
10435
  });
10405
10436
 
@@ -10428,6 +10459,7 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10428
10459
  ON_CAMERA_RESUMED: ON_CAMERA_RESUMED,
10429
10460
  ON_CALL_CANCELED: ON_CALL_CANCELED,
10430
10461
  ON_CALL_FAILED: ON_CALL_FAILED,
10462
+ ON_CALL_REJECTED: ON_CALL_REJECTED,
10431
10463
  ON_CALL_ENDED: ON_CALL_ENDED,
10432
10464
  ON_CALL_ENDING: ON_CALL_ENDING,
10433
10465
  ON_MESSAGE: ON_MESSAGE,
@@ -10457,6 +10489,14 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10457
10489
  'default': WebRTCPhone
10458
10490
  });
10459
10491
 
10492
+ /* */
10493
+ class SFUNotAvailableError extends Error {
10494
+ constructor(message = 'Sorry your user is not configured to support video conference') {
10495
+ super(message);
10496
+ this.name = 'SFUNotAvailableError';
10497
+ }
10498
+ }
10499
+
10460
10500
  //
10461
10501
 
10462
10502
  const logger$6 = IssueReporter$1.loggerFor('simple-phone');
@@ -10841,7 +10881,7 @@ class Phone extends Emitter {
10841
10881
 
10842
10882
  checkSfu() {
10843
10883
  if (!this.hasSfu()) {
10844
- throw new Error('Sorry your user is not configured to support video conference');
10884
+ throw new SFUNotAvailableError();
10845
10885
  }
10846
10886
  }
10847
10887
 
@@ -13738,6 +13778,7 @@ const Wazo = {
13738
13778
  InvalidSubscription,
13739
13779
  InvalidAuthorization,
13740
13780
  CanceledCallError,
13781
+ SFUNotAvailableError,
13741
13782
  };
13742
13783
 
13743
13784
  if (window) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wazo/sdk",
3
- "version": "0.37.27",
3
+ "version": "0.37.28",
4
4
  "description": "Wazo's JavaScript Software Development Kit.",
5
5
  "main": "dist/wazo-sdk.js",
6
6
  "author": "Wazo (http://wazo.io)",
@@ -1,5 +1,6 @@
1
1
  // @flow
2
2
  import { SessionState } from 'sip.js/lib/api/session-state';
3
+ import type { Session } from 'sip.js/lib/api/session';
3
4
 
4
5
  import Call from './Call';
5
6
  import newFrom from '../utils/new-from';
@@ -12,8 +13,10 @@ type CallSessionArguments = {
12
13
  callId: string,
13
14
  callerNumber: string,
14
15
  cameraEnabled: boolean,
16
+ creationTime?: ?Date,
15
17
  dialedExtension?: string | null,
16
18
  displayName: string,
19
+ endTime?: ?Date,
17
20
  isCaller: boolean,
18
21
  muted: boolean,
19
22
  videoMuted: boolean,
@@ -30,6 +33,7 @@ type CallSessionArguments = {
30
33
  screensharing: boolean,
31
34
  recording: boolean,
32
35
  recordingPaused: boolean,
36
+ sipSession?: Session,
33
37
  };
34
38
 
35
39
  export default class CallSession {
@@ -49,8 +53,12 @@ export default class CallSession {
49
53
 
50
54
  callerNumber: string;
51
55
 
56
+ creationTime: ?Date;
57
+
52
58
  startTime: number;
53
59
 
60
+ endTime: ?Date;
61
+
54
62
  isCaller: boolean;
55
63
 
56
64
  answered: boolean;
@@ -89,6 +97,8 @@ export default class CallSession {
89
97
 
90
98
  recordingPaused: boolean;
91
99
 
100
+ sipSession: Session;
101
+
92
102
  constructor({
93
103
  answered,
94
104
  answeredBySystem,
@@ -101,6 +111,8 @@ export default class CallSession {
101
111
  paused,
102
112
  ringing,
103
113
  startTime,
114
+ creationTime,
115
+ endTime,
104
116
  cameraEnabled,
105
117
  dialedExtension,
106
118
  sipCallId,
@@ -113,12 +125,15 @@ export default class CallSession {
113
125
  recording,
114
126
  recordingPaused,
115
127
  videoRemotelyDowngraded,
128
+ sipSession,
116
129
  }: CallSessionArguments) {
117
130
  this.callId = callId;
118
131
  this.sipCallId = sipCallId;
119
132
  this.displayName = displayName;
120
133
  this.number = number;
134
+ this.creationTime = creationTime;
121
135
  this.startTime = startTime;
136
+ this.endTime = endTime;
122
137
  this.isCaller = isCaller;
123
138
  this.answered = answered;
124
139
  this.answeredBySystem = answeredBySystem;
@@ -137,6 +152,7 @@ export default class CallSession {
137
152
  this.recording = recording || false;
138
153
  this.recordingPaused = recordingPaused || false;
139
154
  this.videoRemotelyDowngraded = videoRemotelyDowngraded;
155
+ this.sipSession = sipSession;
140
156
 
141
157
  // Useful to compare instead of instanceof with minified code
142
158
  this.type = 'CallSession';
@@ -30,6 +30,7 @@ export const ON_CAMERA_DISABLED = 'onCameraDisabled';
30
30
  export const ON_CAMERA_RESUMED = 'onCameraResumed';
31
31
  export const ON_CALL_CANCELED = 'onCallCanceled';
32
32
  export const ON_CALL_FAILED = 'onCallFailed';
33
+ export const ON_CALL_REJECTED = 'onCallRejected';
33
34
  export const ON_CALL_ENDED = 'onCallEnded';
34
35
  export const ON_CALL_ENDING = 'onCallEnding';
35
36
  export const ON_MESSAGE = 'onMessage';
@@ -74,6 +75,7 @@ export const events = [
74
75
  ON_CAMERA_DISABLED,
75
76
  ON_CALL_FAILED,
76
77
  ON_CALL_ENDED,
78
+ ON_CALL_REJECTED,
77
79
  ON_MESSAGE,
78
80
  ON_REINVITE,
79
81
  ON_TRACK,
@@ -430,6 +432,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
430
432
 
431
433
  // Should be called before `_onCallTerminated` or the callCount will not decrement...
432
434
  const callSession = this._createCallSession(sipSession);
435
+ callSession.endTime = new Date();
433
436
  const wasCurrentSession = this._onCallTerminated(sipSession);
434
437
 
435
438
  return this.eventEmitter.emit(ON_CALL_ENDED, callSession, wasCurrentSession);
@@ -1151,6 +1154,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
1151
1154
  return Promise.resolve(null);
1152
1155
  }
1153
1156
  const callSession = this._createOutgoingCallSession(sipSession, cameraEnabled || false);
1157
+ callSession.creationTime = new Date();
1154
1158
 
1155
1159
  this.eventEmitter.emit(ON_PLAY_PROGRESS_SOUND, this.audioOutputDeviceId, this.audioOutputVolume);
1156
1160
 
@@ -1429,6 +1433,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
1429
1433
  callSession);
1430
1434
  }
1431
1435
 
1436
+ callSession.creationTime = new Date();
1432
1437
  this.eventEmitter.emit(ON_CALL_INCOMING, callSession, wantsToDoVideo);
1433
1438
  });
1434
1439
 
@@ -1468,6 +1473,13 @@ export default class WebRTCPhone extends Emitter implements Phone {
1468
1473
  this.eventEmitter.emit(ON_CALL_ERROR, e);
1469
1474
  });
1470
1475
 
1476
+ this.client.on(this.client.REJECTED, session => {
1477
+ logger.info('WebRTC call rejected', session.id);
1478
+ const callSession = this._createCallSession(session);
1479
+ callSession.endTime = new Date();
1480
+ this.eventEmitter.emit(ON_CALL_REJECTED, callSession);
1481
+ });
1482
+
1471
1483
  this.client.on(this.client.UNREGISTERED, () => {
1472
1484
  logger.info('WebRTC unregistered');
1473
1485
  this.eventEmitter.emit(ON_UNREGISTERED);
@@ -1682,6 +1694,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
1682
1694
  const number = identity ? identity.uri._normal.user : null;
1683
1695
  const { state } = sipSession || {};
1684
1696
  const sessionId = this.getSipSessionId(sipSession);
1697
+ fromSession = fromSession || this.callSessions[sessionId];
1685
1698
 
1686
1699
  const callSession = new CallSession({
1687
1700
  callId: fromSession && fromSession.callId,
@@ -1689,6 +1702,8 @@ export default class WebRTCPhone extends Emitter implements Phone {
1689
1702
  sipStatus: state,
1690
1703
  displayName: identity ? identity.displayName || number : number,
1691
1704
  startTime: fromSession ? fromSession.startTime : new Date(),
1705
+ creationTime: fromSession ? fromSession.creationTime : null,
1706
+ endTime: fromSession ? fromSession.endTime : null,
1692
1707
  answered: state === SessionState.Established,
1693
1708
  paused: this.client.isCallHeld(sipSession),
1694
1709
  isCaller: 'incoming' in extra ? !extra.incoming : false,
@@ -1699,6 +1714,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
1699
1714
  videoMuted: fromSession ? fromSession.isVideoMuted() : false,
1700
1715
  recording: fromSession ? fromSession.isRecording() : false,
1701
1716
  recordingPaused: false, // @TODO
1717
+ sipSession,
1702
1718
  ...extra,
1703
1719
  });
1704
1720
 
@@ -0,0 +1,7 @@
1
+ /* @flow */
2
+ export default class SFUNotAvailableError extends Error {
3
+ constructor(message: string = 'Sorry your user is not configured to support video conference') {
4
+ super(message);
5
+ this.name = 'SFUNotAvailableError';
6
+ }
7
+ }
package/src/index.js CHANGED
@@ -9,6 +9,7 @@ import IssueReporter from './service/IssueReporter';
9
9
  // Domain
10
10
  import BadResponse from './domain/BadResponse';
11
11
  import ServerError from './domain/ServerError';
12
+ import SFUNotAvailableError from './domain/SFUNotAvailableError';
12
13
  import Call from './domain/Call';
13
14
  import CallLog from './domain/CallLog';
14
15
  import Recording from './domain/Recording';
@@ -95,6 +96,7 @@ export default {
95
96
  WazoWebSocketClient: WebSocketClient,
96
97
  BadResponse,
97
98
  ServerError,
99
+ SFUNotAvailableError,
98
100
  Call,
99
101
  CallSession,
100
102
  CTIPhone,
@@ -14,6 +14,7 @@ import IssueReporter from '../service/IssueReporter';
14
14
  import Emitter from '../utils/Emitter';
15
15
 
16
16
  import Wazo from './index';
17
+ import SFUNotAvailableError from '../domain/SFUNotAvailableError';
17
18
 
18
19
  const logger = IssueReporter.loggerFor('simple-phone');
19
20
  const sipLogger = IssueReporter.loggerFor('sip.js');
@@ -397,7 +398,7 @@ class Phone extends Emitter {
397
398
 
398
399
  checkSfu() {
399
400
  if (!this.hasSfu()) {
400
- throw new Error('Sorry your user is not configured to support video conference');
401
+ throw new SFUNotAvailableError();
401
402
  }
402
403
  }
403
404
 
@@ -15,6 +15,7 @@ import { CanceledCallError } from '../web-rtc-client';
15
15
 
16
16
  import BadResponse from '../domain/BadResponse';
17
17
  import ServerError from '../domain/ServerError';
18
+ import SFUNotAvailableError from '../domain/SFUNotAvailableError';
18
19
  import Call from '../domain/Call';
19
20
  import CallLog from '../domain/CallLog';
20
21
  import Recording from '../domain/Recording';
@@ -101,6 +102,7 @@ const Wazo = {
101
102
  InvalidSubscription,
102
103
  InvalidAuthorization,
103
104
  CanceledCallError,
105
+ SFUNotAvailableError,
104
106
  };
105
107
 
106
108
  if (window) {