ggez-banking-sdk 0.3.3 → 0.3.4
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.
|
@@ -19,17 +19,8 @@ declare class CookiesHelper {
|
|
|
19
19
|
* Check if we're in a secure context (HTTPS or localhost)
|
|
20
20
|
*/
|
|
21
21
|
private isSecureContext;
|
|
22
|
-
/**
|
|
23
|
-
* Fallback method to set cookie using document.cookie
|
|
24
|
-
*/
|
|
25
22
|
private setCookieFallback;
|
|
26
|
-
/**
|
|
27
|
-
* Fallback method to get cookie using document.cookie
|
|
28
|
-
*/
|
|
29
23
|
private getCookieFallback;
|
|
30
|
-
/**
|
|
31
|
-
* Fallback method to delete cookie using document.cookie
|
|
32
|
-
*/
|
|
33
24
|
private deleteCookieFallback;
|
|
34
25
|
GetIID(): Promise<string>;
|
|
35
26
|
SetIID(): Promise<string>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { v4 } from "uuid";
|
|
2
|
+
import DocumentCookie from "js-cookie";
|
|
2
3
|
import { CipherHelper } from "../cipherHelper";
|
|
3
4
|
class CookiesHelper {
|
|
4
5
|
// #region "Properties"
|
|
@@ -15,7 +16,6 @@ class CookiesHelper {
|
|
|
15
16
|
this.key = v4();
|
|
16
17
|
this.programId = programId;
|
|
17
18
|
this.errorHandler = errorHandler;
|
|
18
|
-
// Format domain properly (add leading dot for subdomain sharing if not present)
|
|
19
19
|
this.domain = domain;
|
|
20
20
|
// Check if cookieStore API is available (requires HTTPS or localhost)
|
|
21
21
|
this.useCookieStore = this.isCookieStoreAvailable();
|
|
@@ -23,6 +23,8 @@ class CookiesHelper {
|
|
|
23
23
|
this.Cookies = window.cookieStore;
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
+
// #endregion
|
|
27
|
+
// #region "Utils"
|
|
26
28
|
/**
|
|
27
29
|
* Check if CookieStore API is available
|
|
28
30
|
* CookieStore requires secure context (HTTPS or localhost)
|
|
@@ -41,53 +43,28 @@ class CookiesHelper {
|
|
|
41
43
|
return false;
|
|
42
44
|
return window.isSecureContext;
|
|
43
45
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
*/
|
|
46
|
+
// #endregion
|
|
47
|
+
// #region "Fallback Methods"
|
|
47
48
|
setCookieFallback(name, value, expires, domain) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
57
|
-
// Set secure flag only in HTTPS
|
|
58
|
-
if (this.isSecureContext()) {
|
|
59
|
-
cookieString += `; secure`;
|
|
60
|
-
}
|
|
61
|
-
cookieString += `; samesite=lax`;
|
|
62
|
-
document.cookie = cookieString;
|
|
49
|
+
const isSecure = this.isSecureContext();
|
|
50
|
+
DocumentCookie.set(name, value, {
|
|
51
|
+
expires: expires ? new Date(expires) : undefined,
|
|
52
|
+
path: "/",
|
|
53
|
+
domain: domain,
|
|
54
|
+
secure: isSecure,
|
|
55
|
+
sameSite: isSecure ? "none" : "lax",
|
|
56
|
+
});
|
|
63
57
|
}
|
|
64
|
-
/**
|
|
65
|
-
* Fallback method to get cookie using document.cookie
|
|
66
|
-
*/
|
|
67
58
|
getCookieFallback(name) {
|
|
68
59
|
if (typeof document === "undefined")
|
|
69
60
|
return "";
|
|
70
|
-
|
|
71
|
-
const ca = document.cookie.split(";");
|
|
72
|
-
for (let i = 0; i < ca.length; i++) {
|
|
73
|
-
let c = ca[i];
|
|
74
|
-
while (c.charAt(0) === " ")
|
|
75
|
-
c = c.substring(1, c.length);
|
|
76
|
-
if (c.indexOf(nameEQ) === 0) {
|
|
77
|
-
return decodeURIComponent(c.substring(nameEQ.length, c.length));
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
return "";
|
|
61
|
+
return DocumentCookie.get(name) || "";
|
|
81
62
|
}
|
|
82
|
-
/**
|
|
83
|
-
* Fallback method to delete cookie using document.cookie
|
|
84
|
-
*/
|
|
85
63
|
deleteCookieFallback(name, domain) {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
90
|
-
document.cookie = cookieString;
|
|
64
|
+
DocumentCookie.remove(name, {
|
|
65
|
+
path: "/",
|
|
66
|
+
domain: domain,
|
|
67
|
+
});
|
|
91
68
|
}
|
|
92
69
|
// #endregion
|
|
93
70
|
// #region "IID"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ggez-banking-sdk",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.4",
|
|
4
4
|
"description": "A Node.js package to handle GGEZ Banking API endpoints, Simplify the process of managing CRUD operations with this efficient and easy-to-use package.",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"main": "dist/index.js",
|