@wazo/sdk 0.37.37 → 0.37.40

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 (74) hide show
  1. package/README.md +2 -1
  2. package/dist/wazo-sdk.js +2 -2
  3. package/esm/__tests__/api-client.test.js +9 -0
  4. package/esm/__tests__/web-rtc-client.test.js +15 -3
  5. package/esm/api/auth.js +2 -0
  6. package/esm/api-client.js +9 -0
  7. package/esm/checker/Checker.js +15 -3
  8. package/esm/checker/checks/aor.js +9 -0
  9. package/esm/checker/checks/api.js +9 -0
  10. package/esm/checker/checks/index.js +15 -3
  11. package/esm/checker/checks/webrtc-transport.js +15 -3
  12. package/esm/checker/checks/webrtc.js +15 -3
  13. package/esm/domain/AdHocAPIConference.js +14 -5
  14. package/esm/domain/Features.js +9 -0
  15. package/esm/domain/Phone/CTIPhone.js +9 -0
  16. package/esm/domain/Phone/WebRTCPhone.js +1 -1
  17. package/esm/domain/SwitchboardCall.js +5 -5
  18. package/esm/index.js +33 -14
  19. package/esm/service/CallApi.js +9 -0
  20. package/esm/service/getApiClient.js +9 -0
  21. package/esm/simple/Auth.js +33 -14
  22. package/esm/simple/Configuration.js +33 -14
  23. package/esm/simple/Directory.js +9 -0
  24. package/esm/simple/Phone.js +33 -14
  25. package/esm/simple/index.js +33 -14
  26. package/esm/simple/room/LocalParticipant.js +33 -14
  27. package/esm/simple/room/Participant.js +33 -14
  28. package/esm/simple/room/RemoteParticipant.js +33 -14
  29. package/esm/simple/room/Room.js +33 -14
  30. package/esm/simple/room/SipRoom.js +33 -14
  31. package/esm/simple/room/Stream.js +33 -14
  32. package/esm/simple/room/__tests__/RemoteParticipant.test.js +33 -14
  33. package/esm/simple/utils.js +33 -14
  34. package/esm/web-rtc-client.js +15 -3
  35. package/lib/__tests__/api-client.test.js +9 -0
  36. package/lib/__tests__/web-rtc-client.test.js +15 -3
  37. package/lib/api/auth.js +2 -0
  38. package/lib/api-client.js +9 -0
  39. package/lib/checker/Checker.js +15 -3
  40. package/lib/checker/checks/aor.js +9 -0
  41. package/lib/checker/checks/api.js +9 -0
  42. package/lib/checker/checks/index.js +15 -3
  43. package/lib/checker/checks/webrtc-transport.js +15 -3
  44. package/lib/checker/checks/webrtc.js +15 -3
  45. package/lib/domain/AdHocAPIConference.js +14 -5
  46. package/lib/domain/Features.js +9 -0
  47. package/lib/domain/Phone/CTIPhone.js +9 -0
  48. package/lib/domain/Phone/WebRTCPhone.js +1 -1
  49. package/lib/domain/SwitchboardCall.js +5 -5
  50. package/lib/index.js +33 -14
  51. package/lib/service/CallApi.js +9 -0
  52. package/lib/service/getApiClient.js +9 -0
  53. package/lib/simple/Auth.js +33 -14
  54. package/lib/simple/Configuration.js +33 -14
  55. package/lib/simple/Directory.js +9 -0
  56. package/lib/simple/Phone.js +33 -14
  57. package/lib/simple/index.js +33 -14
  58. package/lib/simple/room/LocalParticipant.js +33 -14
  59. package/lib/simple/room/Participant.js +33 -14
  60. package/lib/simple/room/RemoteParticipant.js +33 -14
  61. package/lib/simple/room/Room.js +33 -14
  62. package/lib/simple/room/SipRoom.js +33 -14
  63. package/lib/simple/room/Stream.js +33 -14
  64. package/lib/simple/room/__tests__/RemoteParticipant.test.js +33 -14
  65. package/lib/simple/utils.js +33 -14
  66. package/lib/web-rtc-client.js +15 -3
  67. package/package.json +1 -1
  68. package/src/api/auth.js +2 -0
  69. package/src/api-client.js +7 -0
  70. package/src/domain/AdHocAPIConference.js +5 -5
  71. package/src/domain/Phone/WebRTCPhone.js +1 -1
  72. package/src/domain/SwitchboardCall.js +5 -5
  73. package/src/simple/Auth.js +7 -0
  74. package/src/web-rtc-client.js +7 -4
@@ -2797,12 +2797,14 @@ var authMethods = (client , baseUrl ) => ({
2797
2797
  backend ,
2798
2798
  expiration ,
2799
2799
  isMobile = false,
2800
+ tenantId ,
2800
2801
  ) => {
2801
2802
  const body = {
2802
2803
  backend: backend || DEFAULT_BACKEND_USER,
2803
2804
  expiration: expiration || DETAULT_EXPIRATION,
2804
2805
  refresh_token: refreshToken,
2805
2806
  client_id: client.clientId,
2807
+ tenant_id: tenantId,
2806
2808
  };
2807
2809
 
2808
2810
  const headers = {
@@ -5140,6 +5142,7 @@ class ApiClient {
5140
5142
 
5141
5143
 
5142
5144
 
5145
+
5143
5146
 
5144
5147
 
5145
5148
 
@@ -5180,6 +5183,7 @@ class ApiClient {
5180
5183
  logger$1.info('refresh token callback called', {
5181
5184
  refreshToken: this.refreshToken,
5182
5185
  refreshBackend: this.refreshBackend,
5186
+ refreshTenantId: this.refreshTenantId,
5183
5187
  refreshExpiration: this.refreshExpiration,
5184
5188
  isMobile: this.isMobile,
5185
5189
  });
@@ -5193,6 +5197,7 @@ class ApiClient {
5193
5197
  this.refreshBackend,
5194
5198
  this.refreshExpiration,
5195
5199
  this.isMobile,
5200
+ this.refreshTenantId,
5196
5201
  );
5197
5202
 
5198
5203
  logger$1.info('token refreshed', { token: session.token });
@@ -5234,6 +5239,10 @@ class ApiClient {
5234
5239
  this.refreshBackend = refreshBackend;
5235
5240
  }
5236
5241
 
5242
+ setRefreshTenantId(tenantId ) {
5243
+ this.refreshTenantId = tenantId;
5244
+ }
5245
+
5237
5246
  setIsMobile(isMobile ) {
5238
5247
  this.isMobile = isMobile;
5239
5248
  }
@@ -7402,11 +7411,14 @@ class WebRTCClient extends Emitter {
7402
7411
  }
7403
7412
 
7404
7413
  async _disconnectTransport(force = false) {
7405
- if (force) {
7414
+ if (force && this.userAgent && this.userAgent.transport) {
7406
7415
  // Bypass sip.js state machine that prevent to close WS with the state `Connecting`
7407
7416
  this.userAgent.transport.disconnectResolve = () => {};
7408
- // eslint-disable-next-line
7409
- this.userAgent.transport._ws.close(1000);
7417
+
7418
+ if (this.userAgent.transport._ws) {
7419
+ this.userAgent.transport._ws.close(1000);
7420
+ }
7421
+
7410
7422
  return;
7411
7423
  }
7412
7424
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wazo/sdk",
3
- "version": "0.37.37",
3
+ "version": "0.37.40",
4
4
  "description": "Wazo's JavaScript Software Development Kit.",
5
5
  "main": "dist/wazo-sdk.js",
6
6
  "author": "Wazo (http://wazo.io)",
package/src/api/auth.js CHANGED
@@ -67,12 +67,14 @@ export default (client: ApiRequester, baseUrl: string) => ({
67
67
  backend: string,
68
68
  expiration: number,
69
69
  isMobile: boolean = false,
70
+ tenantId: ?string,
70
71
  ): Promise<?Session> => {
71
72
  const body: Object = {
72
73
  backend: backend || DEFAULT_BACKEND_USER,
73
74
  expiration: expiration || DETAULT_EXPIRATION,
74
75
  refresh_token: refreshToken,
75
76
  client_id: client.clientId,
77
+ tenant_id: tenantId,
76
78
  };
77
79
 
78
80
  const headers: Object = {
package/src/api-client.js CHANGED
@@ -55,6 +55,7 @@ export default class ApiClient {
55
55
  onRefreshToken: ?Function;
56
56
  refreshExpiration: ?number;
57
57
  refreshBackend: ?string;
58
+ refreshTenantId: ?string;
58
59
  isMobile: boolean;
59
60
  fetchOptions: Object;
60
61
 
@@ -95,6 +96,7 @@ export default class ApiClient {
95
96
  logger.info('refresh token callback called', {
96
97
  refreshToken: this.refreshToken,
97
98
  refreshBackend: this.refreshBackend,
99
+ refreshTenantId: this.refreshTenantId,
98
100
  refreshExpiration: this.refreshExpiration,
99
101
  isMobile: this.isMobile,
100
102
  });
@@ -108,6 +110,7 @@ export default class ApiClient {
108
110
  this.refreshBackend,
109
111
  this.refreshExpiration,
110
112
  this.isMobile,
113
+ this.refreshTenantId,
111
114
  );
112
115
 
113
116
  logger.info('token refreshed', { token: session.token });
@@ -149,6 +152,10 @@ export default class ApiClient {
149
152
  this.refreshBackend = refreshBackend;
150
153
  }
151
154
 
155
+ setRefreshTenantId(tenantId: ?string) {
156
+ this.refreshTenantId = tenantId;
157
+ }
158
+
152
159
  setIsMobile(isMobile: boolean) {
153
160
  this.isMobile = isMobile;
154
161
  }
@@ -27,7 +27,7 @@ export type ConferenceArguments = {
27
27
  finished?: boolean,
28
28
  participants: {[string]: CallSession};
29
29
  started?: boolean,
30
- startTime?: ?number,
30
+ answerTime?: ?number,
31
31
  conferenceId?: ?string,
32
32
  muted?: boolean,
33
33
  paused?: boolean,
@@ -47,7 +47,7 @@ export default class AdHocAPIConference {
47
47
 
48
48
  conferenceId: string;
49
49
 
50
- startTime: ?number;
50
+ answerTime: ?number;
51
51
 
52
52
  muted: boolean;
53
53
 
@@ -59,7 +59,7 @@ export default class AdHocAPIConference {
59
59
  participants,
60
60
  started,
61
61
  finished,
62
- startTime,
62
+ answerTime,
63
63
  conferenceId,
64
64
  muted,
65
65
  paused,
@@ -69,7 +69,7 @@ export default class AdHocAPIConference {
69
69
  this.participants = participants || {};
70
70
  this.started = started || false;
71
71
  this.finished = finished || false;
72
- this.startTime = startTime;
72
+ this.answerTime = answerTime;
73
73
  this.conferenceId = conferenceId || '';
74
74
  this.muted = muted || false;
75
75
  this.paused = paused || false;
@@ -82,7 +82,7 @@ export default class AdHocAPIConference {
82
82
  async start() {
83
83
  this.started = true;
84
84
  // $FlowFixMe
85
- this.startTime = Object.values(this.participants).length ? Object.values(this.participants)[0].startTime : null;
85
+ this.answerTime = Object.values(this.participants).length ? Object.values(this.participants)[0].answerTime : null;
86
86
 
87
87
  const participantIds = Object.keys(this.participants);
88
88
  const conference = await getApiClient().calld.createAdHocConference(this.host.callId, participantIds);
@@ -1563,7 +1563,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
1563
1563
  });
1564
1564
 
1565
1565
  this.client.on(this.client.DISCONNECTED, () => {
1566
- logger.info('WebRTC client disconnected');
1566
+ logger.warn('WebRTC client disconnected');
1567
1567
 
1568
1568
  this.eventEmitter.emit(ON_UNREGISTERED);
1569
1569
 
@@ -28,7 +28,7 @@ type SwitchboardCallArguments = {
28
28
  callSession: ?CallSession,
29
29
  callerIdName: ?string,
30
30
  callerIdNumber: ?string,
31
- startTime: ?Date,
31
+ answerTime: ?Date,
32
32
  participantId: ?string,
33
33
  state: string,
34
34
  switchboardName: string,
@@ -54,7 +54,7 @@ class SwitchboardCall {
54
54
  callSession: ?CallSession;
55
55
  callerIdName: ?string;
56
56
  callerIdNumber: ?string;
57
- startTime: ?Date;
57
+ answerTime: ?Date;
58
58
  participantId: ?string;
59
59
  state: string;
60
60
  switchboardName: string;
@@ -68,7 +68,7 @@ class SwitchboardCall {
68
68
  callerIdName: plain.caller_id_name || null,
69
69
  callerIdNumber: plain.caller_id_number || null,
70
70
  participantId: plain.participantId || null,
71
- startTime: plain.startTime,
71
+ answerTime: plain.startTime,
72
72
  state: plain.state,
73
73
  switchboardName: plain.switchboardName,
74
74
  switchboardUuid: plain.switchboardUuid,
@@ -81,7 +81,7 @@ class SwitchboardCall {
81
81
  callerIdName,
82
82
  callerIdNumber,
83
83
  participantId,
84
- startTime,
84
+ answerTime,
85
85
  state,
86
86
  switchboardName,
87
87
  switchboardUuid,
@@ -91,7 +91,7 @@ class SwitchboardCall {
91
91
  this.callerIdName = callerIdName;
92
92
  this.callerIdNumber = callerIdNumber;
93
93
  this.participantId = participantId;
94
- this.startTime = startTime;
94
+ this.answerTime = answerTime;
95
95
  this.state = state;
96
96
  this.switchboardName = switchboardName;
97
97
  this.switchboardUuid = switchboardUuid;
@@ -87,6 +87,13 @@ class Auth {
87
87
  expiration: this.expiration,
88
88
  mobile: this.mobile,
89
89
  });
90
+
91
+ if (backend) {
92
+ getApiClient().setRefreshBackend(backend);
93
+ }
94
+
95
+ getApiClient().setRefreshTenantId(tenantId);
96
+
90
97
  return this._onAuthenticated(rawSession);
91
98
  }
92
99
 
@@ -1,5 +1,5 @@
1
1
  // @flow
2
- /* eslint-disable class-methods-use-this, no-param-reassign, max-classes-per-file */
2
+ /* eslint-disable class-methods-use-this, no-param-reassign, max-classes-per-file, no-underscore-dangle */
3
3
  /* global window, document, navigator */
4
4
  import 'webrtc-adapter';
5
5
  import type InviterInviteOptions from 'sip.js/lib/api/inviter-invite-options';
@@ -2084,11 +2084,14 @@ export default class WebRTCClient extends Emitter {
2084
2084
  }
2085
2085
 
2086
2086
  async _disconnectTransport(force: boolean = false) {
2087
- if (force) {
2087
+ if (force && this.userAgent && this.userAgent.transport) {
2088
2088
  // Bypass sip.js state machine that prevent to close WS with the state `Connecting`
2089
2089
  this.userAgent.transport.disconnectResolve = () => {};
2090
- // eslint-disable-next-line
2091
- this.userAgent.transport._ws.close(1000);
2090
+
2091
+ if (this.userAgent.transport._ws) {
2092
+ this.userAgent.transport._ws.close(1000);
2093
+ }
2094
+
2092
2095
  return;
2093
2096
  }
2094
2097