sea-react-components 1.3.22 → 1.3.24
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.
|
@@ -4,6 +4,7 @@ type AxiosOptions = {
|
|
|
4
4
|
withCredentials?: boolean;
|
|
5
5
|
storage?: "localStorage" | "cookie";
|
|
6
6
|
deviceIdKey?: string;
|
|
7
|
+
cookieDomain?: string;
|
|
7
8
|
};
|
|
8
9
|
export declare const createInstance: (baseURL: string, options?: AxiosOptions) => import("axios").AxiosInstance;
|
|
9
10
|
export default axios;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/axios/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAoC,MAAM,OAAO,CAAC;AAKzD,KAAK,YAAY,GAAG;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,OAAO,CAAC,EAAE,cAAc,GAAG,QAAQ,CAAC;IACpC,WAAW,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/axios/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAoC,MAAM,OAAO,CAAC;AAKzD,KAAK,YAAY,GAAG;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,OAAO,CAAC,EAAE,cAAc,GAAG,QAAQ,CAAC;IACpC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,eAAO,MAAM,cAAc,YAChB,MAAM,YACN,YAAY,kCAgEtB,CAAC;AAEF,eAAe,KAAK,CAAC"}
|
|
@@ -7,6 +7,7 @@ export const createInstance = (baseURL, options = {
|
|
|
7
7
|
JWTTokenKey: "JWTToken",
|
|
8
8
|
storage: "localStorage",
|
|
9
9
|
deviceIdKey: CONSTANTS.Server.DEVICE_ID_HEADER_KEY,
|
|
10
|
+
cookieDomain: ".platform.sea.ac.ae", // TODO: fix the hardcoded value
|
|
10
11
|
}) => {
|
|
11
12
|
const axiosInstance = axios.create({
|
|
12
13
|
baseURL,
|
|
@@ -42,10 +43,8 @@ export const createInstance = (baseURL, options = {
|
|
|
42
43
|
CONSTANTS.Server.ERROR_MESSAGES.REVOKED_TOKEN,
|
|
43
44
|
].includes(message)) {
|
|
44
45
|
console.log("Unauthenticated or invalid input - logging out");
|
|
45
|
-
removeCookie(options.JWTTokenKey);
|
|
46
|
-
|
|
47
|
-
window.location.reload();
|
|
48
|
-
}, 2000);
|
|
46
|
+
removeCookie(options.JWTTokenKey, options.cookieDomain);
|
|
47
|
+
window.location.reload();
|
|
49
48
|
}
|
|
50
49
|
return Promise.reject((_d = error.response) === null || _d === void 0 ? void 0 : _d.data);
|
|
51
50
|
});
|
|
@@ -6,5 +6,5 @@ export declare const setCookie: (name: string, value: string, options?: {
|
|
|
6
6
|
secure?: boolean;
|
|
7
7
|
sameSite?: "Strict" | "Lax" | "None";
|
|
8
8
|
}) => void;
|
|
9
|
-
export declare const removeCookie: (name: string) => void;
|
|
9
|
+
export declare const removeCookie: (name: string, domain?: string) => void;
|
|
10
10
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/cookie/index.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS,SAAU,MAAM,KAAG,MAAM,GAAG,SAMjD,CAAC;AAEF,eAAO,MAAM,SAAS,SACd,MAAM,SACL,MAAM,YACH;IACR,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,QAAQ,GAAG,KAAK,GAAG,MAAM,CAAC;CACtC,KACA,IAiBF,CAAC;AAEF,eAAO,MAAM,YAAY,SAAU,MAAM,KAAG,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/cookie/index.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS,SAAU,MAAM,KAAG,MAAM,GAAG,SAMjD,CAAC;AAEF,eAAO,MAAM,SAAS,SACd,MAAM,SACL,MAAM,YACH;IACR,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,QAAQ,GAAG,KAAK,GAAG,MAAM,CAAC;CACtC,KACA,IAiBF,CAAC;AAEF,eAAO,MAAM,YAAY,SAAU,MAAM,WAAW,MAAM,KAAG,IAsB5D,CAAC"}
|
|
@@ -25,17 +25,21 @@ export const setCookie = (name, value, options) => {
|
|
|
25
25
|
cookie += ` SameSite=${options.sameSite};`;
|
|
26
26
|
document.cookie = cookie;
|
|
27
27
|
};
|
|
28
|
-
export const removeCookie = (name) => {
|
|
29
|
-
console.log("removeCookie:
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
export const removeCookie = (name, domain) => {
|
|
29
|
+
console.log("removeCookie:", name);
|
|
30
|
+
const possibleDomains = [
|
|
31
|
+
window.location.hostname,
|
|
32
|
+
`.${window.location.hostname}`,
|
|
33
|
+
];
|
|
34
|
+
if (domain)
|
|
35
|
+
possibleDomains.push(domain);
|
|
32
36
|
const paths = ["/", ""];
|
|
33
|
-
console.log({
|
|
34
|
-
|
|
37
|
+
console.log({ possibleDomains, paths });
|
|
38
|
+
possibleDomains.forEach((domain) => {
|
|
35
39
|
paths.forEach((path) => {
|
|
36
40
|
document.cookie = `${name}=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=${path}; domain=${domain};`;
|
|
37
41
|
});
|
|
38
42
|
});
|
|
39
|
-
// Also try without domain
|
|
43
|
+
// Also try without domain just in case
|
|
40
44
|
document.cookie = `${name}=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/;`;
|
|
41
45
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sea-react-components",
|
|
3
3
|
"description": "SEA react components library",
|
|
4
|
-
"version": "1.3.
|
|
4
|
+
"version": "1.3.24",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"build": "tsc --build && npx postcss src/styles.css -o dist/styles.css && npx postcss src/components/text-editor/style.css -o dist/components/text-editor/style.css",
|