phx-react 1.3.1582 → 1.3.1583
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.
|
@@ -1,23 +1,41 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = PHXFuncGetCookieSession;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
4
5
|
const constants_1 = require("../../utils/constants");
|
|
5
6
|
const helpers_1 = require("../../helpers/helpers");
|
|
6
7
|
const sessionStore_1 = require("./sessionStore");
|
|
7
8
|
const save_local_storage_1 = require("./save-local-storage");
|
|
9
|
+
const js_cookie_1 = tslib_1.__importDefault(require("js-cookie"));
|
|
8
10
|
function PHXFuncGetCookieSession() {
|
|
9
|
-
let sessionInfo;
|
|
10
11
|
const cachedSession = (0, sessionStore_1.getSession)();
|
|
11
12
|
if (cachedSession)
|
|
12
13
|
return cachedSession;
|
|
13
|
-
if (typeof window
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const
|
|
14
|
+
if (typeof window === 'undefined')
|
|
15
|
+
return null;
|
|
16
|
+
try {
|
|
17
|
+
let sessionInfo = null;
|
|
18
|
+
const data = (0, save_local_storage_1.getLocalStorage)(constants_1.COOKIE_SESSION_SIGN_IN);
|
|
19
|
+
if (data) {
|
|
20
|
+
sessionInfo = JSON.parse(data);
|
|
21
|
+
}
|
|
22
|
+
if (!sessionInfo) {
|
|
23
|
+
const cookieValue = js_cookie_1.default.get(constants_1.COOKIE_SESSION_SIGN_IN);
|
|
24
|
+
if (cookieValue) {
|
|
25
|
+
sessionInfo = cookieValue;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
if (!sessionInfo)
|
|
29
|
+
return null;
|
|
30
|
+
const sessionInfoDecrypt = (0, helpers_1.decryptCookie)(sessionInfo);
|
|
31
|
+
if (!sessionInfoDecrypt)
|
|
32
|
+
return null;
|
|
18
33
|
(0, sessionStore_1.setSession)(sessionInfoDecrypt);
|
|
19
34
|
return sessionInfoDecrypt;
|
|
20
35
|
}
|
|
21
|
-
|
|
36
|
+
catch (error) {
|
|
37
|
+
console.warn('Session error:', error);
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
22
40
|
}
|
|
23
41
|
//# sourceMappingURL=getCookieSession.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getCookieSession.js","sourceRoot":"","sources":["../../../../src/components/Func/getCookieSession.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"getCookieSession.js","sourceRoot":"","sources":["../../../../src/components/Func/getCookieSession.ts"],"names":[],"mappings":";;AAkCA,0CAyBC;;AA3DD,qDAA8D;AAC9D,mDAAqD;AACrD,iDAAuD;AACvD,6DAAsD;AACtD,kEAA+B;AA8B/B,SAAwB,uBAAuB;IAC7C,MAAM,aAAa,GAAG,IAAA,yBAAU,GAAE,CAAA;IAClC,IAAI,aAAa;QAAE,OAAO,aAAa,CAAA;IACvC,IAAI,OAAO,MAAM,KAAK,WAAW;QAAE,OAAO,IAAI,CAAA;IAC9C,IAAI,CAAC;QACH,IAAI,WAAW,GAAQ,IAAI,CAAA;QAC3B,MAAM,IAAI,GAAG,IAAA,oCAAe,EAAS,kCAAsB,CAAC,CAAA;QAC5D,IAAI,IAAI,EAAE,CAAC;YACT,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QAChC,CAAC;QACD,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,MAAM,WAAW,GAAG,mBAAO,CAAC,GAAG,CAAC,kCAAsB,CAAC,CAAA;YACvD,IAAI,WAAW,EAAE,CAAC;gBAChB,WAAW,GAAG,WAAW,CAAA;YAC3B,CAAC;QACH,CAAC;QACD,IAAI,CAAC,WAAW;YAAE,OAAO,IAAI,CAAA;QAC7B,MAAM,kBAAkB,GAAG,IAAA,uBAAa,EAAC,WAAW,CAAC,CAAA;QACrD,IAAI,CAAC,kBAAkB;YAAE,OAAO,IAAI,CAAA;QACpC,IAAA,yBAAU,EAAC,kBAAkB,CAAC,CAAA;QAC9B,OAAO,kBAAkB,CAAA;IAC3B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,IAAI,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAA;QACrC,OAAO,IAAI,CAAA;IACb,CAAC;AACH,CAAC"}
|
|
@@ -2,19 +2,36 @@ import { COOKIE_SESSION_SIGN_IN } from '../../utils/constants';
|
|
|
2
2
|
import { decryptCookie } from '../../helpers/helpers';
|
|
3
3
|
import { getSession, setSession } from './sessionStore';
|
|
4
4
|
import { getLocalStorage } from './save-local-storage';
|
|
5
|
+
import Cookies from 'js-cookie';
|
|
5
6
|
export default function PHXFuncGetCookieSession() {
|
|
6
|
-
let sessionInfo;
|
|
7
7
|
const cachedSession = getSession();
|
|
8
8
|
if (cachedSession)
|
|
9
9
|
return cachedSession;
|
|
10
|
-
if (typeof window
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const
|
|
10
|
+
if (typeof window === 'undefined')
|
|
11
|
+
return null;
|
|
12
|
+
try {
|
|
13
|
+
let sessionInfo = null;
|
|
14
|
+
const data = getLocalStorage(COOKIE_SESSION_SIGN_IN);
|
|
15
|
+
if (data) {
|
|
16
|
+
sessionInfo = JSON.parse(data);
|
|
17
|
+
}
|
|
18
|
+
if (!sessionInfo) {
|
|
19
|
+
const cookieValue = Cookies.get(COOKIE_SESSION_SIGN_IN);
|
|
20
|
+
if (cookieValue) {
|
|
21
|
+
sessionInfo = cookieValue;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
if (!sessionInfo)
|
|
25
|
+
return null;
|
|
26
|
+
const sessionInfoDecrypt = decryptCookie(sessionInfo);
|
|
27
|
+
if (!sessionInfoDecrypt)
|
|
28
|
+
return null;
|
|
15
29
|
setSession(sessionInfoDecrypt);
|
|
16
30
|
return sessionInfoDecrypt;
|
|
17
31
|
}
|
|
18
|
-
|
|
32
|
+
catch (error) {
|
|
33
|
+
console.warn('Session error:', error);
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
19
36
|
}
|
|
20
37
|
//# sourceMappingURL=getCookieSession.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getCookieSession.js","sourceRoot":"","sources":["../../../../src/components/Func/getCookieSession.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAA;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AACrD,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;
|
|
1
|
+
{"version":3,"file":"getCookieSession.js","sourceRoot":"","sources":["../../../../src/components/Func/getCookieSession.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAA;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AACrD,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,OAAO,MAAM,WAAW,CAAA;AA8B/B,MAAM,CAAC,OAAO,UAAU,uBAAuB;IAC7C,MAAM,aAAa,GAAG,UAAU,EAAE,CAAA;IAClC,IAAI,aAAa;QAAE,OAAO,aAAa,CAAA;IACvC,IAAI,OAAO,MAAM,KAAK,WAAW;QAAE,OAAO,IAAI,CAAA;IAC9C,IAAI,CAAC;QACH,IAAI,WAAW,GAAQ,IAAI,CAAA;QAC3B,MAAM,IAAI,GAAG,eAAe,CAAS,sBAAsB,CAAC,CAAA;QAC5D,IAAI,IAAI,EAAE,CAAC;YACT,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QAChC,CAAC;QACD,I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