@wazo/sdk 0.38.9 → 0.38.10

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 (76) hide show
  1. package/dist/wazo-sdk.js +2 -2
  2. package/esm/__tests__/api-client.test.js +21 -0
  3. package/esm/__tests__/web-rtc-client.test.js +21 -0
  4. package/esm/api/auth.js +12 -0
  5. package/esm/api/ctid-ng.js +1 -0
  6. package/esm/api-client.js +21 -0
  7. package/esm/checker/Checker.js +21 -0
  8. package/esm/checker/checks/aor.js +21 -0
  9. package/esm/checker/checks/api.js +21 -0
  10. package/esm/checker/checks/index.js +21 -0
  11. package/esm/checker/checks/webrtc-transport.js +21 -0
  12. package/esm/checker/checks/webrtc.js +21 -0
  13. package/esm/domain/AdHocAPIConference.js +28 -2
  14. package/esm/domain/Features.js +28 -2
  15. package/esm/domain/Phone/CTIPhone.js +28 -2
  16. package/esm/domain/Phone/WebRTCPhone.js +1 -0
  17. package/esm/index.js +73 -6
  18. package/esm/service/CallApi.js +28 -2
  19. package/esm/service/getApiClient.js +34 -3
  20. package/esm/simple/Auth.js +74 -7
  21. package/esm/simple/Configuration.js +73 -6
  22. package/esm/simple/Directory.js +28 -2
  23. package/esm/simple/Phone.js +73 -6
  24. package/esm/simple/Softphone.js +5 -0
  25. package/esm/simple/index.js +73 -6
  26. package/esm/simple/room/LocalParticipant.js +73 -6
  27. package/esm/simple/room/Participant.js +73 -6
  28. package/esm/simple/room/RemoteParticipant.js +73 -6
  29. package/esm/simple/room/Room.js +73 -6
  30. package/esm/simple/room/SipRoom.js +73 -6
  31. package/esm/simple/room/Stream.js +73 -6
  32. package/esm/simple/room/__tests__/Participant.test.js +73 -6
  33. package/esm/simple/room/__tests__/RemoteParticipant.test.js +73 -6
  34. package/esm/simple/utils.js +73 -6
  35. package/esm/web-rtc-client.js +21 -0
  36. package/lib/__tests__/api-client.test.js +21 -0
  37. package/lib/__tests__/web-rtc-client.test.js +21 -0
  38. package/lib/api/auth.js +12 -0
  39. package/lib/api/ctid-ng.js +1 -0
  40. package/lib/api-client.js +21 -0
  41. package/lib/checker/Checker.js +21 -0
  42. package/lib/checker/checks/aor.js +21 -0
  43. package/lib/checker/checks/api.js +21 -0
  44. package/lib/checker/checks/index.js +21 -0
  45. package/lib/checker/checks/webrtc-transport.js +21 -0
  46. package/lib/checker/checks/webrtc.js +21 -0
  47. package/lib/domain/AdHocAPIConference.js +28 -2
  48. package/lib/domain/Features.js +28 -2
  49. package/lib/domain/Phone/CTIPhone.js +28 -2
  50. package/lib/domain/Phone/WebRTCPhone.js +1 -0
  51. package/lib/index.js +73 -6
  52. package/lib/service/CallApi.js +28 -2
  53. package/lib/service/getApiClient.js +34 -2
  54. package/lib/simple/Auth.js +74 -6
  55. package/lib/simple/Configuration.js +73 -6
  56. package/lib/simple/Directory.js +28 -2
  57. package/lib/simple/Phone.js +73 -6
  58. package/lib/simple/Softphone.js +5 -0
  59. package/lib/simple/index.js +73 -6
  60. package/lib/simple/room/LocalParticipant.js +73 -6
  61. package/lib/simple/room/Participant.js +73 -6
  62. package/lib/simple/room/RemoteParticipant.js +73 -6
  63. package/lib/simple/room/Room.js +73 -6
  64. package/lib/simple/room/SipRoom.js +73 -6
  65. package/lib/simple/room/Stream.js +73 -6
  66. package/lib/simple/room/__tests__/Participant.test.js +73 -6
  67. package/lib/simple/room/__tests__/RemoteParticipant.test.js +73 -6
  68. package/lib/simple/utils.js +73 -6
  69. package/lib/web-rtc-client.js +21 -0
  70. package/package.json +2 -2
  71. package/src/api/auth.js +12 -0
  72. package/src/api-client.js +8 -0
  73. package/src/service/getApiClient.js +13 -2
  74. package/src/simple/Auth.js +35 -4
  75. package/src/simple/Softphone.js +5 -0
  76. package/src/simple/index.js +2 -1
@@ -2797,6 +2797,7 @@ var authMethods = (client , baseUrl ) => ({
2797
2797
 
2798
2798
 
2799
2799
 
2800
+
2800
2801
  ) {
2801
2802
  const body = {
2802
2803
  backend: params.backend || DEFAULT_BACKEND_USER,
@@ -2817,9 +2818,14 @@ var authMethods = (client , baseUrl ) => ({
2817
2818
  }
2818
2819
 
2819
2820
  if (params.tenantId) {
2821
+ console.warn('Use of `tenantId` is deprecated when calling logIn() method, use `domainName` instead.');
2820
2822
  body.tenant_id = params.tenantId;
2821
2823
  }
2822
2824
 
2825
+ if (params.domainName) {
2826
+ body.domain_name = params.domainName;
2827
+ }
2828
+
2823
2829
  return client.post(`${baseUrl}/token`, body, headers).then(response => Session.parse(response));
2824
2830
  },
2825
2831
 
@@ -2832,6 +2838,7 @@ var authMethods = (client , baseUrl ) => ({
2832
2838
  expiration ,
2833
2839
  isMobile = false,
2834
2840
  tenantId ,
2841
+ domainName ,
2835
2842
  ) => {
2836
2843
  const body = {
2837
2844
  backend: backend || DEFAULT_BACKEND_USER,
@@ -2841,9 +2848,14 @@ var authMethods = (client , baseUrl ) => ({
2841
2848
  };
2842
2849
 
2843
2850
  if (tenantId) {
2851
+ console.warn('Use of `tenantId` is deprecated when calling refreshToken() method, use `domainName` instead.');
2844
2852
  body.tenant_id = tenantId;
2845
2853
  }
2846
2854
 
2855
+ if (domainName) {
2856
+ body.domain_name = domainName;
2857
+ }
2858
+
2847
2859
  const headers = {
2848
2860
  'Content-Type': 'application/json',
2849
2861
  ...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),
@@ -4270,6 +4282,7 @@ global.wazoClientId = global.wazoClientId || {};
4270
4282
  global.wazoClientToken = global.wazoClientToken || {};
4271
4283
  global.wazoRefreshToken = global.wazoRefreshToken || {};
4272
4284
  global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
4285
+ global.wazoRefreshDomainName = global.wazoRefreshDomainName || {};
4273
4286
  global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
4274
4287
  global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
4275
4288
  global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
@@ -5329,6 +5342,7 @@ class ApiClient {
5329
5342
 
5330
5343
 
5331
5344
 
5345
+
5332
5346
 
5333
5347
 
5334
5348
 
@@ -5370,6 +5384,7 @@ class ApiClient {
5370
5384
  refreshToken: this.refreshToken,
5371
5385
  refreshBackend: this.refreshBackend,
5372
5386
  refreshTenantId: this.refreshTenantId,
5387
+ refreshDomainName: this.refreshDomainName,
5373
5388
  refreshExpiration: this.refreshExpiration,
5374
5389
  isMobile: this.isMobile,
5375
5390
  });
@@ -5385,6 +5400,7 @@ class ApiClient {
5385
5400
  this.refreshExpiration,
5386
5401
  this.isMobile,
5387
5402
  this.refreshTenantId,
5403
+ this.refreshDomainName,
5388
5404
  );
5389
5405
 
5390
5406
  logger$1.info('token refreshed', { token: session.token });
@@ -5438,9 +5454,14 @@ class ApiClient {
5438
5454
  }
5439
5455
 
5440
5456
  setRefreshTenantId(tenantId ) {
5457
+ console.warn('Use of `setRefreshTenantId` is deprecated, use `setRefreshDomainName` instead');
5441
5458
  this.refreshTenantId = tenantId;
5442
5459
  }
5443
5460
 
5461
+ setRefreshDomainName(domainName ) {
5462
+ this.refreshDomainName = domainName;
5463
+ }
5464
+
5444
5465
  setIsMobile(isMobile ) {
5445
5466
  this.isMobile = isMobile;
5446
5467
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wazo/sdk",
3
- "version": "0.38.9",
3
+ "version": "0.38.10",
4
4
  "description": "Wazo's JavaScript Software Development Kit.",
5
5
  "main": "dist/wazo-sdk.js",
6
6
  "author": "Wazo (http://wazo.io)",
@@ -100,4 +100,4 @@
100
100
  "react-native": {
101
101
  "node-fetch/lib/index": false
102
102
  }
103
- }
103
+ }
package/src/api/auth.js CHANGED
@@ -33,6 +33,7 @@ export default (client: ApiRequester, baseUrl: string) => ({
33
33
  expiration: number,
34
34
  mobile?: boolean,
35
35
  tenantId?: string,
36
+ domainName?: string,
36
37
  }): Promise<?Session> {
37
38
  const body: Object = {
38
39
  backend: params.backend || DEFAULT_BACKEND_USER,
@@ -53,9 +54,14 @@ export default (client: ApiRequester, baseUrl: string) => ({
53
54
  }
54
55
 
55
56
  if (params.tenantId) {
57
+ console.warn('Use of `tenantId` is deprecated when calling logIn() method, use `domainName` instead.');
56
58
  body.tenant_id = params.tenantId;
57
59
  }
58
60
 
61
+ if (params.domainName) {
62
+ body.domain_name = params.domainName;
63
+ }
64
+
59
65
  return client.post(`${baseUrl}/token`, body, headers).then(response => Session.parse(response));
60
66
  },
61
67
 
@@ -68,6 +74,7 @@ export default (client: ApiRequester, baseUrl: string) => ({
68
74
  expiration: number,
69
75
  isMobile: boolean = false,
70
76
  tenantId: ?string,
77
+ domainName?: string,
71
78
  ): Promise<?Session> => {
72
79
  const body: Object = {
73
80
  backend: backend || DEFAULT_BACKEND_USER,
@@ -77,9 +84,14 @@ export default (client: ApiRequester, baseUrl: string) => ({
77
84
  };
78
85
 
79
86
  if (tenantId) {
87
+ console.warn('Use of `tenantId` is deprecated when calling refreshToken() method, use `domainName` instead.');
80
88
  body.tenant_id = tenantId;
81
89
  }
82
90
 
91
+ if (domainName) {
92
+ body.domain_name = domainName;
93
+ }
94
+
83
95
  const headers: Object = {
84
96
  'Content-Type': 'application/json',
85
97
  ...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),
package/src/api-client.js CHANGED
@@ -57,6 +57,7 @@ export default class ApiClient {
57
57
  refreshExpiration: ?number;
58
58
  refreshBackend: ?string;
59
59
  refreshTenantId: ?string;
60
+ refreshDomainName: ?string;
60
61
  isMobile: boolean;
61
62
  fetchOptions: Object;
62
63
 
@@ -98,6 +99,7 @@ export default class ApiClient {
98
99
  refreshToken: this.refreshToken,
99
100
  refreshBackend: this.refreshBackend,
100
101
  refreshTenantId: this.refreshTenantId,
102
+ refreshDomainName: this.refreshDomainName,
101
103
  refreshExpiration: this.refreshExpiration,
102
104
  isMobile: this.isMobile,
103
105
  });
@@ -113,6 +115,7 @@ export default class ApiClient {
113
115
  this.refreshExpiration,
114
116
  this.isMobile,
115
117
  this.refreshTenantId,
118
+ this.refreshDomainName,
116
119
  );
117
120
 
118
121
  logger.info('token refreshed', { token: session.token });
@@ -166,9 +169,14 @@ export default class ApiClient {
166
169
  }
167
170
 
168
171
  setRefreshTenantId(tenantId: ?string) {
172
+ console.warn('Use of `setRefreshTenantId` is deprecated, use `setRefreshDomainName` instead');
169
173
  this.refreshTenantId = tenantId;
170
174
  }
171
175
 
176
+ setRefreshDomainName(domainName: ?string) {
177
+ this.refreshDomainName = domainName;
178
+ }
179
+
172
180
  setIsMobile(isMobile: boolean) {
173
181
  this.isMobile = isMobile;
174
182
  }
@@ -11,6 +11,7 @@ global.wazoClientId = global.wazoClientId || {};
11
11
  global.wazoClientToken = global.wazoClientToken || {};
12
12
  global.wazoRefreshToken = global.wazoRefreshToken || {};
13
13
  global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
14
+ global.wazoRefreshDomainName = global.wazoRefreshDomainName || {};
14
15
  global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
15
16
  global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
16
17
  global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
@@ -35,9 +36,14 @@ export const setRefreshToken = (newRefreshToken: ?string, forServer: ?string = n
35
36
  };
36
37
 
37
38
  export const setRefreshTenantId = (refreshTenantId: ?string, forServer: ?string = null) => {
39
+ console.warn('Use of `setRefreshTenantId` is deprecated, please use `setRefreshDomainName` instead');
38
40
  global.wazoRefreshTenantId[forServer] = refreshTenantId;
39
41
  };
40
42
 
43
+ export const setRefreshDomainName = (refreshDomainName: ?string, forServer: ?string = null) => {
44
+ global.wazoRefreshDomainName[forServer] = refreshDomainName;
45
+ };
46
+
41
47
  export const setOnRefreshToken = (onRefreshToken: Function, forServer: ?string = null) => {
42
48
  global.wazoOnRefreshToken[forServer] = onRefreshToken;
43
49
  };
@@ -64,6 +70,7 @@ export const setFetchOptions = (fetchOptions: Object, forServer: ?string = null)
64
70
 
65
71
  const fillClient = (apiClient: WazoApiClient) => {
66
72
  const { server, token, clientId } = apiClient.client;
73
+ const tenantId = global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId;
67
74
 
68
75
  // try with null server when dealing with non-related server info
69
76
  apiClient.setToken(global.wazoClientToken[server] || global.wazoClientToken[null] || token);
@@ -72,8 +79,12 @@ const fillClient = (apiClient: WazoApiClient) => {
72
79
 
73
80
  apiClient.setRefreshToken(global.wazoRefreshToken[server] || global.wazoRefreshToken[null] || apiClient.refreshToken);
74
81
 
75
- apiClient.setRefreshTenantId(
76
- global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId,
82
+ if (tenantId) {
83
+ apiClient.setRefreshTenantId(tenantId);
84
+ }
85
+
86
+ apiClient.setRefreshDomainName(
87
+ global.wazoRefreshDomainName[server] || global.wazoRefreshDomainName[null] || apiClient.refreshDomainName,
77
88
  );
78
89
 
79
90
  apiClient.setFetchOptions(global.wazoFetchOptions[server] || global.wazoFetchOptions[null] || apiClient.fetchOptions);
@@ -11,6 +11,7 @@ import getApiClient, {
11
11
  setOnRefreshToken,
12
12
  setFetchOptions,
13
13
  setRefreshTenantId,
14
+ setRefreshDomainName,
14
15
  setOnRefreshTokenError,
15
16
  } from '../service/getApiClient';
16
17
  import IssueReporter from '../service/IssueReporter';
@@ -20,6 +21,7 @@ import Wazo from './index';
20
21
  export class InvalidSubscription extends Error {}
21
22
  export class InvalidAuthorization extends Error {}
22
23
  export class NoTenantIdError extends Error {}
24
+ export class NoDomainNameError extends Error {}
23
25
 
24
26
  const logger = IssueReporter.loggerFor('simple-auth');
25
27
 
@@ -83,9 +85,24 @@ class Auth {
83
85
  setFetchOptions(options);
84
86
  }
85
87
 
86
- async logIn(username: string, password: string, backend?: string, tenantId?: string) {
87
- if (backend && backend !== this.BACKEND_WAZO && !tenantId) {
88
- throw new NoTenantIdError('No tenant id');
88
+ async logIn(username: string, password: string, backend?: string, extra?: string | Object) {
89
+ let tenantId = null;
90
+ let domainName = null;
91
+ if (typeof extra === 'string') {
92
+ tenantId = extra;
93
+ }
94
+ if (extra && typeof extra === 'object') {
95
+ domainName = extra.domainName;
96
+ }
97
+
98
+ if (backend && backend !== this.BACKEND_WAZO && !tenantId && !domainName) {
99
+ if (!tenantId) {
100
+ throw new NoTenantIdError('No tenant id');
101
+ }
102
+
103
+ if (!domainName) {
104
+ throw new NoDomainNameError('No domain name');
105
+ }
89
106
  }
90
107
 
91
108
  this.authenticated = false;
@@ -95,6 +112,7 @@ class Auth {
95
112
  password,
96
113
  backend,
97
114
  tenantId,
115
+ domainName,
98
116
  expiration: this.expiration,
99
117
  mobile: this.mobile,
100
118
  });
@@ -103,7 +121,13 @@ class Auth {
103
121
  getApiClient().setRefreshBackend(backend);
104
122
  }
105
123
 
106
- getApiClient().setRefreshTenantId(tenantId);
124
+ if (tenantId) {
125
+ getApiClient().setRefreshTenantId(tenantId);
126
+ }
127
+
128
+ if (domainName) {
129
+ getApiClient().setRefreshDomainName(domainName);
130
+ }
107
131
 
108
132
  return this._onAuthenticated(rawSession);
109
133
  }
@@ -202,11 +226,18 @@ class Auth {
202
226
  }
203
227
 
204
228
  setRefreshTenantId(refreshTenantId: string) {
229
+ console.warn('Use of `setRefreshTenantId` is deprecated, use `setRefreshDomainName` instead.');
205
230
  setRefreshTenantId(refreshTenantId);
206
231
 
207
232
  getApiClient().setRefreshTenantId(refreshTenantId);
208
233
  }
209
234
 
235
+ setRefreshDomainName(domainName: string) {
236
+ setRefreshDomainName(domainName);
237
+
238
+ getApiClient().setRefreshDomainName(domainName);
239
+ }
240
+
210
241
  forceRefreshToken() {
211
242
  getApiClient().forceRefreshToken();
212
243
  }
@@ -107,6 +107,7 @@ class Softphone {
107
107
  wrapUpDuration,
108
108
  enableAgent = true,
109
109
  tenantId,
110
+ domainName,
110
111
  debug = false,
111
112
  }: Object = {}) {
112
113
  this.url = url || 'https://softphone.wazo.io';
@@ -131,8 +132,12 @@ class Softphone {
131
132
  config.port = port;
132
133
  }
133
134
  if (tenantId) {
135
+ console.warn('Use of `tenantId` is deprecated when calling `Softphone.init()`, use `domainName` instead');
134
136
  config.tenantId = tenantId;
135
137
  }
138
+ if (domainName) {
139
+ config.domainName = domainName;
140
+ }
136
141
  if (wrapUpDuration) {
137
142
  config.wrapUpDuration = wrapUpDuration;
138
143
  }
@@ -1,5 +1,5 @@
1
1
  /* global window */
2
- import Auth, { InvalidSubscription, InvalidAuthorization, NoTenantIdError } from './Auth';
2
+ import Auth, { InvalidSubscription, InvalidAuthorization, NoTenantIdError, NoDomainNameError } from './Auth';
3
3
  import Phone from './Phone';
4
4
  import Websocket from './Websocket';
5
5
  import Room from './room/Room';
@@ -106,6 +106,7 @@ const Wazo = {
106
106
  CanceledCallError,
107
107
  SFUNotAvailableError,
108
108
  NoTenantIdError,
109
+ NoDomainNameError,
109
110
  };
110
111
 
111
112
  if (window) {