conexys-elements 1.1.1 → 1.1.2
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 +26 -18
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +26 -18
- package/dist/index.js.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,8 @@ 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
|
+
return localStorage.getItem('cxauthxc');
|
|
297
305
|
},
|
|
298
306
|
setSessionId(sessionId, configLogs) {
|
|
299
307
|
initializeAuthConfig(configLogs);
|
|
@@ -307,9 +315,8 @@ const authStorage = {
|
|
|
307
315
|
initializeAuthConfig(configLogs);
|
|
308
316
|
if (USE_COOKIES_FOR_AUTH) {
|
|
309
317
|
return this.getCookie('cx_session');
|
|
310
|
-
} else {
|
|
311
|
-
return localStorage.getItem('cx_session');
|
|
312
318
|
}
|
|
319
|
+
return localStorage.getItem('cx_session');
|
|
313
320
|
},
|
|
314
321
|
removeAuthData(configLogs) {
|
|
315
322
|
initializeAuthConfig(configLogs);
|
|
@@ -325,7 +332,8 @@ const authStorage = {
|
|
|
325
332
|
const date = new Date();
|
|
326
333
|
date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);
|
|
327
334
|
const expires = `expires=${date.toUTCString()}`;
|
|
328
|
-
|
|
335
|
+
const secure = window.location.protocol === 'https:' ? ';Secure' : '';
|
|
336
|
+
document.cookie = `${name}=${value};${expires};path=/;SameSite=Strict${secure}`;
|
|
329
337
|
},
|
|
330
338
|
getCookie(name) {
|
|
331
339
|
const nameEQ = `${name}=`;
|