@in.pulse-crm/sdk 1.3.7 → 1.3.8

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.
package/dist/auth.d.ts CHANGED
@@ -45,18 +45,16 @@ export default class AuthSDK {
45
45
  login(instanceName: string, username: string, password: string): Promise<DataResponse<LoginData>>;
46
46
  /**
47
47
  * Busca os dados da sessão.
48
- * @param {string} instanceName Nome da instância do Inpulse.
49
48
  * @param {string} authToken Token de autenticação.
50
49
  * @returns {Promise<DataResponse<AuthTypes.SessionData>>} Dados da sessão.
51
50
  */
52
- fetchSessionData(instanceName: string, authToken: string): Promise<DataResponse<SessionData>>;
51
+ fetchSessionData(authToken: string): Promise<DataResponse<SessionData>>;
53
52
  /**
54
53
  * Busca os dados do usuário da sessão.
55
- * @param {string} instanceName Nome da instância do Inpulse.
56
54
  * @param {string} authToken Token de autenticação.
57
55
  * @returns {Promise<DataResponse<AuthTypes.User>>} Dados do usuário.
58
56
  */
59
- fetchSessionUser(instanceName: string, authToken: string): Promise<DataResponse<User>>;
57
+ fetchSessionUser(authToken: string): Promise<DataResponse<User>>;
60
58
  /**
61
59
  * Verifica se o usuário está autenticado.
62
60
  * @param {string} instanceName Nome da instância do Inpulse.
package/dist/auth.js CHANGED
@@ -26,13 +26,12 @@ class AuthSDK {
26
26
  }
27
27
  /**
28
28
  * Busca os dados da sessão.
29
- * @param {string} instanceName Nome da instância do Inpulse.
30
29
  * @param {string} authToken Token de autenticação.
31
30
  * @returns {Promise<DataResponse<AuthTypes.SessionData>>} Dados da sessão.
32
31
  */
33
- async fetchSessionData(instanceName, authToken) {
32
+ async fetchSessionData(authToken) {
34
33
  const response = await this.httpClient
35
- .get(`/${instanceName}/auth`, {
34
+ .get(`/auth`, {
36
35
  headers: {
37
36
  authorization: authToken,
38
37
  },
@@ -45,13 +44,12 @@ class AuthSDK {
45
44
  }
46
45
  /**
47
46
  * Busca os dados do usuário da sessão.
48
- * @param {string} instanceName Nome da instância do Inpulse.
49
47
  * @param {string} authToken Token de autenticação.
50
48
  * @returns {Promise<DataResponse<AuthTypes.User>>} Dados do usuário.
51
49
  */
52
- async fetchSessionUser(instanceName, authToken) {
50
+ async fetchSessionUser(authToken) {
53
51
  const response = await this.httpClient
54
- .get(`/${instanceName}/auth/user`, {
52
+ .get(`/auth/user`, {
55
53
  headers: {
56
54
  authorization: authToken,
57
55
  },
@@ -70,8 +68,8 @@ class AuthSDK {
70
68
  */
71
69
  async isAuthenticated(instanceName, authToken) {
72
70
  try {
73
- const { data } = await this.fetchSessionData(instanceName, authToken);
74
- return !!data.userId;
71
+ const { data } = await this.fetchSessionData(authToken);
72
+ return !!data.userId && data.instance === instanceName;
75
73
  }
76
74
  catch {
77
75
  return false;
@@ -86,8 +84,8 @@ class AuthSDK {
86
84
  */
87
85
  async isAuthorized(instanceName, authToken, authorizedRoles) {
88
86
  try {
89
- const { data } = await this.fetchSessionData(instanceName, authToken);
90
- return authorizedRoles.includes(data.role);
87
+ const { data } = await this.fetchSessionData(authToken);
88
+ return authorizedRoles.includes(data.role) && data.instance === instanceName;
91
89
  }
92
90
  catch {
93
91
  return false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@in.pulse-crm/sdk",
3
- "version": "1.3.7",
3
+ "version": "1.3.8",
4
4
  "description": "SDKs for abstraction of api consumption of in.pulse-crm application",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",