conexys-elements 1.1.1 → 1.1.3
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/index.esm.js +32 -20
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +32 -20
- package/dist/index.js.map +1 -1
- package/dist/shared/sharedServicesAPI.d.ts.map +1 -1
- package/dist/utilities/authStorage.d.ts +1 -0
- package/dist/utilities/authStorage.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -263,22 +263,31 @@ const config$4 = {
|
|
|
263
263
|
let USE_COOKIES_FOR_AUTH = false;
|
|
264
264
|
let SESSION_EXPIRATION = 365;
|
|
265
265
|
let isConfigInitialized = false;
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
266
|
+
let initPromise = null;
|
|
267
|
+
const initializeAuthConfig = configLogs => {
|
|
268
|
+
if (initPromise) return initPromise;
|
|
269
|
+
initPromise = (async () => {
|
|
270
|
+
if (isConfigInitialized) return;
|
|
271
|
+
const baseURL = Url + 'getsettings';
|
|
272
|
+
try {
|
|
273
|
+
await serviceData(baseURL, {
|
|
274
|
+
keys: 'type_session'
|
|
275
|
+
}, config$4, value => {
|
|
276
|
+
USE_COOKIES_FOR_AUTH = value === 'cookie';
|
|
277
|
+
isConfigInitialized = true;
|
|
278
|
+
}, configLogs);
|
|
279
|
+
} catch (error) {
|
|
280
|
+
logConsole(configLogs, 'error', 'Error loading authentication configuration:', error);
|
|
281
|
+
} finally {
|
|
274
282
|
isConfigInitialized = true;
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
isConfigInitialized = true;
|
|
279
|
-
}
|
|
283
|
+
}
|
|
284
|
+
})();
|
|
285
|
+
return initPromise;
|
|
280
286
|
};
|
|
281
287
|
const authStorage = {
|
|
288
|
+
initialize(configLogs) {
|
|
289
|
+
return initializeAuthConfig(configLogs);
|
|
290
|
+
},
|
|
282
291
|
setAuthToken(token, configLogs) {
|
|
283
292
|
initializeAuthConfig(configLogs);
|
|
284
293
|
if (USE_COOKIES_FOR_AUTH) {
|
|
@@ -291,9 +300,10 @@ const authStorage = {
|
|
|
291
300
|
initializeAuthConfig(configLogs);
|
|
292
301
|
if (USE_COOKIES_FOR_AUTH) {
|
|
293
302
|
return this.getCookie('cxauthxc');
|
|
294
|
-
} else {
|
|
295
|
-
return localStorage.getItem('cxauthxc');
|
|
296
303
|
}
|
|
304
|
+
const local = localStorage.getItem('cxauthxc');
|
|
305
|
+
if (local !== null) return local;
|
|
306
|
+
return this.getCookie('cxauthxc');
|
|
297
307
|
},
|
|
298
308
|
setSessionId(sessionId, configLogs) {
|
|
299
309
|
initializeAuthConfig(configLogs);
|
|
@@ -307,9 +317,10 @@ const authStorage = {
|
|
|
307
317
|
initializeAuthConfig(configLogs);
|
|
308
318
|
if (USE_COOKIES_FOR_AUTH) {
|
|
309
319
|
return this.getCookie('cx_session');
|
|
310
|
-
} else {
|
|
311
|
-
return localStorage.getItem('cx_session');
|
|
312
320
|
}
|
|
321
|
+
const local = localStorage.getItem('cx_session');
|
|
322
|
+
if (local !== null) return local;
|
|
323
|
+
return this.getCookie('cx_session');
|
|
313
324
|
},
|
|
314
325
|
removeAuthData(configLogs) {
|
|
315
326
|
initializeAuthConfig(configLogs);
|
|
@@ -325,7 +336,8 @@ const authStorage = {
|
|
|
325
336
|
const date = new Date();
|
|
326
337
|
date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);
|
|
327
338
|
const expires = `expires=${date.toUTCString()}`;
|
|
328
|
-
|
|
339
|
+
const secure = window.location.protocol === 'https:' ? ';Secure' : '';
|
|
340
|
+
document.cookie = `${name}=${value};${expires};path=/;SameSite=Strict${secure}`;
|
|
329
341
|
},
|
|
330
342
|
getCookie(name) {
|
|
331
343
|
const nameEQ = `${name}=`;
|
|
@@ -10147,8 +10159,8 @@ const initializeSharedServices = () => {
|
|
|
10147
10159
|
},
|
|
10148
10160
|
getAuthData: () => {
|
|
10149
10161
|
return {
|
|
10150
|
-
sessionID:
|
|
10151
|
-
authToken:
|
|
10162
|
+
sessionID: authStorage.getSessionId(configLogs),
|
|
10163
|
+
authToken: authStorage.getAuthToken(configLogs)
|
|
10152
10164
|
};
|
|
10153
10165
|
}
|
|
10154
10166
|
};
|