@zerosls/clm-sdk 2.1.9 → 2.2.0

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.
@@ -7,7 +7,7 @@ function normalizeUrl(url) {
7
7
  //}
8
8
  export const DEFAULT_CONFIG = {
9
9
  baseUrl: "https://zero-api-production.up.railway.app/ZeroApiQA/api/v1", //resolveDefaultBaseUrl(),
10
- organization: "maver",
10
+ organization: "qa",
11
11
  cache: { enabled: true, ttl: 60000 },
12
12
  debug: true,
13
13
  credentials: "include",
@@ -2,70 +2,6 @@ export class AuthApi {
2
2
  constructor(apiClient) {
3
3
  this.apiClient = apiClient;
4
4
  }
5
- /*async login(
6
- credentials: LoginCredentials,
7
- mode: LoginMode = "new"
8
- ): Promise<{ ok: boolean }> {
9
- const path = mode === "legacy" ? "/legacy/login" : "/auth/login";
10
-
11
- console.log(`🔐 Login attempt (${mode}):`, credentials.email);
12
-
13
- const response = await fetch(`${this.apiClient["baseUrl"]}${path}`, {
14
- method: "POST",
15
- headers: {
16
- "Content-Type": "application/json",
17
- "X-Organization": this.apiClient["organization"] || "default-org",
18
- },
19
- credentials: "include",
20
- body: JSON.stringify({
21
- email: credentials.email,
22
- password: credentials.password,
23
- }),
24
- });
25
-
26
- if (!response.ok) {
27
- if (response.status === 401) throw new Error("Invalid credentials");
28
- throw new Error(`Login failed: ${response.status}`);
29
- }
30
-
31
- const data: any = await response.json().catch(() => null);
32
-
33
- if (mode === "legacy") {
34
- // ✅ Token LEGACY (del sistema viejo)
35
- const legacyToken = data?.dataResult?.token || data?.token;
36
-
37
- if (legacyToken) {
38
- if (typeof sessionStorage !== "undefined") {
39
- sessionStorage.setItem("legacy_token", legacyToken);
40
- }
41
- if (typeof window !== "undefined") {
42
- (window as any).__LEGACY_TOKEN__ = legacyToken;
43
- }
44
- console.log("✅ Legacy token saved");
45
- } else {
46
- console.warn("⚠️ No legacy token received");
47
- }
48
- } else {
49
- // ✅ Token NUEVO (del sistema moderno)
50
- const newToken = data?.token;
51
-
52
- if (newToken) {
53
- if (typeof sessionStorage !== "undefined") {
54
- sessionStorage.setItem("auth_token", newToken);
55
- }
56
- if (typeof window !== "undefined") {
57
- (window as any).__AUTH_TOKEN__ = newToken;
58
- }
59
- console.log("✅ Auth token saved");
60
- } else {
61
- console.warn("⚠️ No auth token received");
62
- }
63
- }
64
-
65
- this.apiClient.setToken(null);
66
-
67
- return { ok: true };
68
- }*/
69
5
  async login(credentials, mode = "new") {
70
6
  var _a;
71
7
  const path = mode === "legacy" ? "/legacy/login" : "/auth/login";
@@ -74,7 +10,7 @@ export class AuthApi {
74
10
  method: "POST",
75
11
  headers: {
76
12
  "Content-Type": "application/json",
77
- "X-Organization": this.apiClient["organization"] || "maver",
13
+ "X-Organization": this.apiClient["organization"] || "qa",
78
14
  },
79
15
  credentials: "include",
80
16
  body: JSON.stringify({
@@ -88,11 +24,10 @@ export class AuthApi {
88
24
  throw new Error("Invalid credentials");
89
25
  throw new Error(`Login failed: ${response.status}`);
90
26
  }
91
- // ✅ Lee el JSON con manejo de errores
92
27
  let data;
93
28
  try {
94
29
  data = await response.json();
95
- console.log(`📦 Response data (${mode}):`, data); // ✅ Agrega esto
30
+ console.log(`📦 Response data (${mode}):`, data);
96
31
  }
97
32
  catch (error) {
98
33
  console.error("❌ Error parsing JSON:", error);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zerosls/clm-sdk",
3
- "version": "2.1.9",
3
+ "version": "2.2.0",
4
4
  "description": "SDK for ZeroCLM API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -11,7 +11,7 @@ function normalizeUrl(url: string) {
11
11
 
12
12
  export const DEFAULT_CONFIG: Partial<SdkConfig> = {
13
13
  baseUrl: "https://zero-api-production.up.railway.app/ZeroApiQA/api/v1", //resolveDefaultBaseUrl(),
14
- organization: "maver",
14
+ organization: "qa",
15
15
  cache: { enabled: true, ttl: 60000 },
16
16
  debug: true,
17
17
  credentials: "include",
@@ -10,70 +10,6 @@ export class AuthApi {
10
10
  this.apiClient = apiClient;
11
11
  }
12
12
 
13
- /*async login(
14
- credentials: LoginCredentials,
15
- mode: LoginMode = "new"
16
- ): Promise<{ ok: boolean }> {
17
- const path = mode === "legacy" ? "/legacy/login" : "/auth/login";
18
-
19
- console.log(`🔐 Login attempt (${mode}):`, credentials.email);
20
-
21
- const response = await fetch(`${this.apiClient["baseUrl"]}${path}`, {
22
- method: "POST",
23
- headers: {
24
- "Content-Type": "application/json",
25
- "X-Organization": this.apiClient["organization"] || "default-org",
26
- },
27
- credentials: "include",
28
- body: JSON.stringify({
29
- email: credentials.email,
30
- password: credentials.password,
31
- }),
32
- });
33
-
34
- if (!response.ok) {
35
- if (response.status === 401) throw new Error("Invalid credentials");
36
- throw new Error(`Login failed: ${response.status}`);
37
- }
38
-
39
- const data: any = await response.json().catch(() => null);
40
-
41
- if (mode === "legacy") {
42
- // ✅ Token LEGACY (del sistema viejo)
43
- const legacyToken = data?.dataResult?.token || data?.token;
44
-
45
- if (legacyToken) {
46
- if (typeof sessionStorage !== "undefined") {
47
- sessionStorage.setItem("legacy_token", legacyToken);
48
- }
49
- if (typeof window !== "undefined") {
50
- (window as any).__LEGACY_TOKEN__ = legacyToken;
51
- }
52
- console.log("✅ Legacy token saved");
53
- } else {
54
- console.warn("⚠️ No legacy token received");
55
- }
56
- } else {
57
- // ✅ Token NUEVO (del sistema moderno)
58
- const newToken = data?.token;
59
-
60
- if (newToken) {
61
- if (typeof sessionStorage !== "undefined") {
62
- sessionStorage.setItem("auth_token", newToken);
63
- }
64
- if (typeof window !== "undefined") {
65
- (window as any).__AUTH_TOKEN__ = newToken;
66
- }
67
- console.log("✅ Auth token saved");
68
- } else {
69
- console.warn("⚠️ No auth token received");
70
- }
71
- }
72
-
73
- this.apiClient.setToken(null);
74
-
75
- return { ok: true };
76
- }*/
77
13
  async login(
78
14
  credentials: LoginCredentials,
79
15
  mode: LoginMode = "new"
@@ -86,7 +22,7 @@ export class AuthApi {
86
22
  method: "POST",
87
23
  headers: {
88
24
  "Content-Type": "application/json",
89
- "X-Organization": this.apiClient["organization"] || "maver",
25
+ "X-Organization": this.apiClient["organization"] || "qa",
90
26
  },
91
27
  credentials: "include",
92
28
  body: JSON.stringify({
@@ -101,11 +37,10 @@ export class AuthApi {
101
37
  throw new Error(`Login failed: ${response.status}`);
102
38
  }
103
39
 
104
- // ✅ Lee el JSON con manejo de errores
105
40
  let data: any;
106
41
  try {
107
42
  data = await response.json();
108
- console.log(`📦 Response data (${mode}):`, data); // ✅ Agrega esto
43
+ console.log(`📦 Response data (${mode}):`, data);
109
44
  } catch (error) {
110
45
  console.error("❌ Error parsing JSON:", error);
111
46
  return { ok: false };