@zerosls/clm-sdk 2.1.7 → 2.1.9

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: "qa",
10
+ organization: "maver",
11
11
  cache: { enabled: true, ttl: 60000 },
12
12
  debug: true,
13
13
  credentials: "include",
@@ -8,51 +8,6 @@ export class AuthApi {
8
8
  ): Promise<{ ok: boolean }> {
9
9
  const path = mode === "legacy" ? "/legacy/login" : "/auth/login";
10
10
 
11
- const response = await fetch(`${this.apiClient["baseUrl"]}${path}`, {
12
- method: "POST",
13
- headers: {
14
- "Content-Type": "application/json",
15
- "X-Organization": this.apiClient["organization"] || "default-org",
16
- },
17
- credentials: "include",
18
- body: JSON.stringify({
19
- email: credentials.email,
20
- password: credentials.password,
21
- }),
22
- });
23
-
24
- if (!response.ok) {
25
- if (response.status === 401) throw new Error("Invalid credentials");
26
- throw new Error(`Login failed: ${response.status}`);
27
- }
28
-
29
- const data: any = await response.json().catch(() => null);
30
-
31
- // ✅ Si es legacy, guarda Bearer token para siguientes llamadas legacy
32
- if (mode === "legacy") {
33
- const legacyToken = data?.dataResult?.token || data?.token;
34
-
35
- if (legacyToken) {
36
- if (typeof sessionStorage !== "undefined") {
37
- sessionStorage.setItem("legacy_token", legacyToken);
38
- }
39
- if (typeof window !== "undefined") {
40
- (window as any).__LEGACY_TOKEN__ = legacyToken;
41
- }
42
- }
43
- }
44
-
45
- // ✅ Nuevo: cookie HttpOnly, no guardes token en memoria del SDK
46
- this.apiClient.setToken(null);
47
-
48
- return { ok: true };
49
- }*/
50
- /*async login(
51
- credentials: LoginCredentials,
52
- mode: LoginMode = "new"
53
- ): Promise<{ ok: boolean }> {
54
- const path = mode === "legacy" ? "/legacy/login" : "/auth/login";
55
-
56
11
  console.log(`🔐 Login attempt (${mode}):`, credentials.email);
57
12
 
58
13
  const response = await fetch(`${this.apiClient["baseUrl"]}${path}`, {
@@ -119,7 +74,7 @@ export class AuthApi {
119
74
  method: "POST",
120
75
  headers: {
121
76
  "Content-Type": "application/json",
122
- "X-Organization": this.apiClient["organization"] || "qa",
77
+ "X-Organization": this.apiClient["organization"] || "maver",
123
78
  },
124
79
  credentials: "include",
125
80
  body: JSON.stringify({
@@ -194,22 +149,6 @@ export class AuthApi {
194
149
  this.apiClient.setToken(response.token);
195
150
  return response;
196
151
  }
197
- /*async logout(): Promise<void> {
198
- try {
199
- await this.apiClient.post<void>("/auth/logout");
200
- } finally {
201
- // limpia token nuevo
202
- this.apiClient.setToken(null);
203
-
204
- // limpia legacy token
205
- if (typeof sessionStorage !== "undefined") {
206
- sessionStorage.removeItem("legacy_token");
207
- }
208
- if (typeof window !== "undefined") {
209
- delete (window as any).__LEGACY_TOKEN__;
210
- }
211
- }
212
- }*/
213
152
  async logout() {
214
153
  try {
215
154
  await this.apiClient.post("/auth/logout");
@@ -231,15 +170,6 @@ export class AuthApi {
231
170
  }
232
171
  }
233
172
  }
234
- //isAuthenticated(): boolean {
235
- // const hasToken = this.apiClient.getToken() !== null;
236
- // const hasLegacy =
237
- // (typeof sessionStorage !== "undefined" &&
238
- // !!sessionStorage.getItem("legacy_token")) ||
239
- // (typeof window !== "undefined" && !!(window as any).__LEGACY_TOKEN__);
240
- //
241
- // return hasToken || hasLegacy;
242
- //}
243
173
  setToken(token) {
244
174
  this.apiClient.setToken(token);
245
175
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zerosls/clm-sdk",
3
- "version": "2.1.7",
3
+ "version": "2.1.9",
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: "qa",
14
+ organization: "maver",
15
15
  cache: { enabled: true, ttl: 60000 },
16
16
  debug: true,
17
17
  credentials: "include",
@@ -10,52 +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
- const response = await fetch(`${this.apiClient["baseUrl"]}${path}`, {
20
- method: "POST",
21
- headers: {
22
- "Content-Type": "application/json",
23
- "X-Organization": this.apiClient["organization"] || "default-org",
24
- },
25
- credentials: "include",
26
- body: JSON.stringify({
27
- email: credentials.email,
28
- password: credentials.password,
29
- }),
30
- });
31
-
32
- if (!response.ok) {
33
- if (response.status === 401) throw new Error("Invalid credentials");
34
- throw new Error(`Login failed: ${response.status}`);
35
- }
36
-
37
- const data: any = await response.json().catch(() => null);
38
-
39
- // ✅ Si es legacy, guarda Bearer token para siguientes llamadas legacy
40
- if (mode === "legacy") {
41
- const legacyToken = data?.dataResult?.token || data?.token;
42
-
43
- if (legacyToken) {
44
- if (typeof sessionStorage !== "undefined") {
45
- sessionStorage.setItem("legacy_token", legacyToken);
46
- }
47
- if (typeof window !== "undefined") {
48
- (window as any).__LEGACY_TOKEN__ = legacyToken;
49
- }
50
- }
51
- }
52
-
53
- // ✅ Nuevo: cookie HttpOnly, no guardes token en memoria del SDK
54
- this.apiClient.setToken(null);
55
-
56
- return { ok: true };
57
- }*/
58
-
59
13
  /*async login(
60
14
  credentials: LoginCredentials,
61
15
  mode: LoginMode = "new"
@@ -132,7 +86,7 @@ export class AuthApi {
132
86
  method: "POST",
133
87
  headers: {
134
88
  "Content-Type": "application/json",
135
- "X-Organization": this.apiClient["organization"] || "qa",
89
+ "X-Organization": this.apiClient["organization"] || "maver",
136
90
  },
137
91
  credentials: "include",
138
92
  body: JSON.stringify({
@@ -218,23 +172,6 @@ export class AuthApi {
218
172
  return response;
219
173
  }
220
174
 
221
- /*async logout(): Promise<void> {
222
- try {
223
- await this.apiClient.post<void>("/auth/logout");
224
- } finally {
225
- // limpia token nuevo
226
- this.apiClient.setToken(null);
227
-
228
- // limpia legacy token
229
- if (typeof sessionStorage !== "undefined") {
230
- sessionStorage.removeItem("legacy_token");
231
- }
232
- if (typeof window !== "undefined") {
233
- delete (window as any).__LEGACY_TOKEN__;
234
- }
235
- }
236
- }*/
237
-
238
175
  async logout(): Promise<void> {
239
176
  try {
240
177
  await this.apiClient.post<void>("/auth/logout");
@@ -257,16 +194,6 @@ export class AuthApi {
257
194
  }
258
195
  }
259
196
 
260
- //isAuthenticated(): boolean {
261
- // const hasToken = this.apiClient.getToken() !== null;
262
- // const hasLegacy =
263
- // (typeof sessionStorage !== "undefined" &&
264
- // !!sessionStorage.getItem("legacy_token")) ||
265
- // (typeof window !== "undefined" && !!(window as any).__LEGACY_TOKEN__);
266
- //
267
- // return hasToken || hasLegacy;
268
- //}
269
-
270
197
  setToken(token: string | null): void {
271
198
  this.apiClient.setToken(token);
272
199
  }