@wazo/sdk 0.37.36 → 0.37.37

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.
@@ -2218,6 +2218,7 @@ class Session {
2218
2218
  /* */
2219
2219
 
2220
2220
  const DEFAULT_BACKEND_USER = 'wazo_user';
2221
+ const BACKEND_LDAP_USER = 'ldap_user';
2221
2222
  const DETAULT_EXPIRATION = 3600;
2222
2223
 
2223
2224
  var authMethods = (client , baseUrl ) => ({
@@ -5619,6 +5620,7 @@ var getApiClient = (forServer ) => {
5619
5620
 
5620
5621
  class InvalidSubscription extends Error {}
5621
5622
  class InvalidAuthorization extends Error {}
5623
+ class NoTenantIdError extends Error {}
5622
5624
 
5623
5625
  const logger$9 = IssueReporter$1.loggerFor('simple-auth');
5624
5626
 
@@ -5632,11 +5634,15 @@ class Auth {
5632
5634
 
5633
5635
 
5634
5636
 
5637
+
5638
+
5635
5639
 
5636
5640
  constructor() {
5637
5641
  this.expiration = DETAULT_EXPIRATION;
5638
5642
  this.authenticated = false;
5639
5643
  this.minSubscriptionType = null;
5644
+ this.BACKEND_WAZO = DEFAULT_BACKEND_USER;
5645
+ this.BACKEND_LDAP = BACKEND_LDAP_USER;
5640
5646
  }
5641
5647
 
5642
5648
  init(clientId ,
@@ -5669,12 +5675,18 @@ class Auth {
5669
5675
  setFetchOptions(options);
5670
5676
  }
5671
5677
 
5672
- async logIn(username , password ) {
5678
+ async logIn(username , password , backend , tenantId ) {
5679
+ if (backend && backend !== this.BACKEND_WAZO && !tenantId) {
5680
+ throw new NoTenantIdError('No tenant id');
5681
+ }
5682
+
5673
5683
  this.authenticated = false;
5674
5684
  this.session = null;
5675
5685
  const rawSession = await getApiClient().auth.logIn({
5676
5686
  username,
5677
5687
  password,
5688
+ backend,
5689
+ tenantId,
5678
5690
  expiration: this.expiration,
5679
5691
  mobile: this.mobile,
5680
5692
  });
@@ -13814,6 +13826,7 @@ const Wazo = {
13814
13826
  InvalidAuthorization,
13815
13827
  CanceledCallError,
13816
13828
  SFUNotAvailableError,
13829
+ NoTenantIdError,
13817
13830
  };
13818
13831
 
13819
13832
  if (window) {
@@ -2218,6 +2218,7 @@ class ApiRequester {
2218
2218
  /* */
2219
2219
 
2220
2220
  const DEFAULT_BACKEND_USER = 'wazo_user';
2221
+ const BACKEND_LDAP_USER = 'ldap_user';
2221
2222
  const DETAULT_EXPIRATION = 3600;
2222
2223
 
2223
2224
  var authMethods = (client , baseUrl ) => ({
@@ -5619,6 +5620,7 @@ var getApiClient = (forServer ) => {
5619
5620
 
5620
5621
  class InvalidSubscription extends Error {}
5621
5622
  class InvalidAuthorization extends Error {}
5623
+ class NoTenantIdError extends Error {}
5622
5624
 
5623
5625
  const logger$9 = IssueReporter$1.loggerFor('simple-auth');
5624
5626
 
@@ -5632,11 +5634,15 @@ class Auth {
5632
5634
 
5633
5635
 
5634
5636
 
5637
+
5638
+
5635
5639
 
5636
5640
  constructor() {
5637
5641
  this.expiration = DETAULT_EXPIRATION;
5638
5642
  this.authenticated = false;
5639
5643
  this.minSubscriptionType = null;
5644
+ this.BACKEND_WAZO = DEFAULT_BACKEND_USER;
5645
+ this.BACKEND_LDAP = BACKEND_LDAP_USER;
5640
5646
  }
5641
5647
 
5642
5648
  init(clientId ,
@@ -5669,12 +5675,18 @@ class Auth {
5669
5675
  setFetchOptions(options);
5670
5676
  }
5671
5677
 
5672
- async logIn(username , password ) {
5678
+ async logIn(username , password , backend , tenantId ) {
5679
+ if (backend && backend !== this.BACKEND_WAZO && !tenantId) {
5680
+ throw new NoTenantIdError('No tenant id');
5681
+ }
5682
+
5673
5683
  this.authenticated = false;
5674
5684
  this.session = null;
5675
5685
  const rawSession = await getApiClient().auth.logIn({
5676
5686
  username,
5677
5687
  password,
5688
+ backend,
5689
+ tenantId,
5678
5690
  expiration: this.expiration,
5679
5691
  mobile: this.mobile,
5680
5692
  });
@@ -13895,6 +13907,7 @@ const Wazo = {
13895
13907
  InvalidAuthorization,
13896
13908
  CanceledCallError,
13897
13909
  SFUNotAvailableError,
13910
+ NoTenantIdError,
13898
13911
  };
13899
13912
 
13900
13913
  if (window) {
@@ -2218,6 +2218,7 @@ class ApiRequester {
2218
2218
  /* */
2219
2219
 
2220
2220
  const DEFAULT_BACKEND_USER = 'wazo_user';
2221
+ const BACKEND_LDAP_USER = 'ldap_user';
2221
2222
  const DETAULT_EXPIRATION = 3600;
2222
2223
 
2223
2224
  var authMethods = (client , baseUrl ) => ({
@@ -5619,6 +5620,7 @@ var getApiClient = (forServer ) => {
5619
5620
 
5620
5621
  class InvalidSubscription extends Error {}
5621
5622
  class InvalidAuthorization extends Error {}
5623
+ class NoTenantIdError extends Error {}
5622
5624
 
5623
5625
  const logger$9 = IssueReporter$1.loggerFor('simple-auth');
5624
5626
 
@@ -5632,11 +5634,15 @@ class Auth {
5632
5634
 
5633
5635
 
5634
5636
 
5637
+
5638
+
5635
5639
 
5636
5640
  constructor() {
5637
5641
  this.expiration = DETAULT_EXPIRATION;
5638
5642
  this.authenticated = false;
5639
5643
  this.minSubscriptionType = null;
5644
+ this.BACKEND_WAZO = DEFAULT_BACKEND_USER;
5645
+ this.BACKEND_LDAP = BACKEND_LDAP_USER;
5640
5646
  }
5641
5647
 
5642
5648
  init(clientId ,
@@ -5669,12 +5675,18 @@ class Auth {
5669
5675
  setFetchOptions(options);
5670
5676
  }
5671
5677
 
5672
- async logIn(username , password ) {
5678
+ async logIn(username , password , backend , tenantId ) {
5679
+ if (backend && backend !== this.BACKEND_WAZO && !tenantId) {
5680
+ throw new NoTenantIdError('No tenant id');
5681
+ }
5682
+
5673
5683
  this.authenticated = false;
5674
5684
  this.session = null;
5675
5685
  const rawSession = await getApiClient().auth.logIn({
5676
5686
  username,
5677
5687
  password,
5688
+ backend,
5689
+ tenantId,
5678
5690
  expiration: this.expiration,
5679
5691
  mobile: this.mobile,
5680
5692
  });
@@ -13953,6 +13965,7 @@ const Wazo = {
13953
13965
  InvalidAuthorization,
13954
13966
  CanceledCallError,
13955
13967
  SFUNotAvailableError,
13968
+ NoTenantIdError,
13956
13969
  };
13957
13970
 
13958
13971
  if (window) {
@@ -2220,6 +2220,7 @@ class ApiRequester {
2220
2220
  /* */
2221
2221
 
2222
2222
  const DEFAULT_BACKEND_USER = 'wazo_user';
2223
+ const BACKEND_LDAP_USER = 'ldap_user';
2223
2224
  const DETAULT_EXPIRATION = 3600;
2224
2225
 
2225
2226
  var authMethods = (client , baseUrl ) => ({
@@ -5621,6 +5622,7 @@ var getApiClient = (forServer ) => {
5621
5622
 
5622
5623
  class InvalidSubscription extends Error {}
5623
5624
  class InvalidAuthorization extends Error {}
5625
+ class NoTenantIdError extends Error {}
5624
5626
 
5625
5627
  const logger$9 = IssueReporter$1.loggerFor('simple-auth');
5626
5628
 
@@ -5634,11 +5636,15 @@ class Auth {
5634
5636
 
5635
5637
 
5636
5638
 
5639
+
5640
+
5637
5641
 
5638
5642
  constructor() {
5639
5643
  this.expiration = DETAULT_EXPIRATION;
5640
5644
  this.authenticated = false;
5641
5645
  this.minSubscriptionType = null;
5646
+ this.BACKEND_WAZO = DEFAULT_BACKEND_USER;
5647
+ this.BACKEND_LDAP = BACKEND_LDAP_USER;
5642
5648
  }
5643
5649
 
5644
5650
  init(clientId ,
@@ -5671,12 +5677,18 @@ class Auth {
5671
5677
  setFetchOptions(options);
5672
5678
  }
5673
5679
 
5674
- async logIn(username , password ) {
5680
+ async logIn(username , password , backend , tenantId ) {
5681
+ if (backend && backend !== this.BACKEND_WAZO && !tenantId) {
5682
+ throw new NoTenantIdError('No tenant id');
5683
+ }
5684
+
5675
5685
  this.authenticated = false;
5676
5686
  this.session = null;
5677
5687
  const rawSession = await getApiClient().auth.logIn({
5678
5688
  username,
5679
5689
  password,
5690
+ backend,
5691
+ tenantId,
5680
5692
  expiration: this.expiration,
5681
5693
  mobile: this.mobile,
5682
5694
  });
@@ -13939,6 +13951,7 @@ const Wazo = {
13939
13951
  InvalidAuthorization,
13940
13952
  CanceledCallError,
13941
13953
  SFUNotAvailableError,
13954
+ NoTenantIdError,
13942
13955
  };
13943
13956
 
13944
13957
  if (window) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wazo/sdk",
3
- "version": "0.37.36",
3
+ "version": "0.37.37",
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
@@ -16,7 +16,8 @@ import type {
16
16
  } from '../domain/types';
17
17
  import Session from '../domain/Session';
18
18
 
19
- const DEFAULT_BACKEND_USER = 'wazo_user';
19
+ export const DEFAULT_BACKEND_USER = 'wazo_user';
20
+ export const BACKEND_LDAP_USER = 'ldap_user';
20
21
  export const DETAULT_EXPIRATION = 3600;
21
22
 
22
23
  export default (client: ApiRequester, baseUrl: string) => ({
@@ -1,7 +1,7 @@
1
1
  // @flow
2
2
  /* eslint-disable max-classes-per-file */
3
3
  import Session from '../domain/Session';
4
- import { DETAULT_EXPIRATION } from '../api/auth';
4
+ import { BACKEND_LDAP_USER, DEFAULT_BACKEND_USER, DETAULT_EXPIRATION } from '../api/auth';
5
5
  import getApiClient, {
6
6
  setCurrentServer,
7
7
  setApiToken,
@@ -17,6 +17,7 @@ import Wazo from './index';
17
17
 
18
18
  export class InvalidSubscription extends Error {}
19
19
  export class InvalidAuthorization extends Error {}
20
+ export class NoTenantIdError extends Error {}
20
21
 
21
22
  const logger = IssueReporter.loggerFor('simple-auth');
22
23
 
@@ -30,11 +31,15 @@ class Auth {
30
31
  onRefreshTokenCallback: ?Function;
31
32
  authenticated: boolean;
32
33
  mobile: boolean;
34
+ BACKEND_WAZO: string;
35
+ BACKEND_LDAP: string;
33
36
 
34
37
  constructor() {
35
38
  this.expiration = DETAULT_EXPIRATION;
36
39
  this.authenticated = false;
37
40
  this.minSubscriptionType = null;
41
+ this.BACKEND_WAZO = DEFAULT_BACKEND_USER;
42
+ this.BACKEND_LDAP = BACKEND_LDAP_USER;
38
43
  }
39
44
 
40
45
  init(clientId: string,
@@ -67,12 +72,18 @@ class Auth {
67
72
  setFetchOptions(options);
68
73
  }
69
74
 
70
- async logIn(username: string, password: string) {
75
+ async logIn(username: string, password: string, backend?: string, tenantId?: string) {
76
+ if (backend && backend !== this.BACKEND_WAZO && !tenantId) {
77
+ throw new NoTenantIdError('No tenant id');
78
+ }
79
+
71
80
  this.authenticated = false;
72
81
  this.session = null;
73
82
  const rawSession = await getApiClient().auth.logIn({
74
83
  username,
75
84
  password,
85
+ backend,
86
+ tenantId,
76
87
  expiration: this.expiration,
77
88
  mobile: this.mobile,
78
89
  });
@@ -1,5 +1,5 @@
1
1
  /* global window */
2
- import Auth, { InvalidSubscription, InvalidAuthorization } from './Auth';
2
+ import Auth, { InvalidSubscription, InvalidAuthorization, NoTenantIdError } from './Auth';
3
3
  import Phone from './Phone';
4
4
  import Websocket from './Websocket';
5
5
  import Room from './room/Room';
@@ -103,6 +103,7 @@ const Wazo = {
103
103
  InvalidAuthorization,
104
104
  CanceledCallError,
105
105
  SFUNotAvailableError,
106
+ NoTenantIdError,
106
107
  };
107
108
 
108
109
  if (window) {