@blotoutio/providers-blotout-wallet-sdk 0.60.0 → 0.61.0

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/index.cjs.js CHANGED
@@ -64,28 +64,39 @@ const cartTokenTwoCookie = 'cart2';
64
64
  const cartTokenLinkCookie = 'bwCartLinkToken';
65
65
 
66
66
  const getCookieValue = (key) => {
67
+ var _a;
67
68
  try {
68
69
  if (!document || !document.cookie) {
69
70
  return '';
70
71
  }
71
- const name = `${key}=`;
72
- const decodedCookie = decodeURIComponent(document.cookie);
73
- const ca = decodedCookie.split(';');
74
- for (let i = 0; i < ca.length; i++) {
75
- let c = ca[i];
76
- while (c.charAt(0) === ' ') {
77
- c = c.substring(1);
78
- }
79
- if (c.indexOf(name) === 0) {
80
- return c.substring(name.length, c.length);
81
- }
82
- }
83
- return '';
72
+ const cookies = parseCookies(document.cookie);
73
+ return (_a = cookies[key]) !== null && _a !== void 0 ? _a : '';
84
74
  }
85
75
  catch {
86
76
  return '';
87
77
  }
88
78
  };
79
+ const parseCookies = (cookie) => {
80
+ return Object.fromEntries(cookie
81
+ .split(/;\s+/)
82
+ .map((r) => r.split('=').map((str) => str.trim()))
83
+ .map(([cookieKey, cookieValue]) => {
84
+ if (!cookieKey) {
85
+ return [];
86
+ }
87
+ let decodedValue = '';
88
+ if (cookieValue) {
89
+ try {
90
+ decodedValue = decodeURIComponent(cookieValue);
91
+ }
92
+ catch (e) {
93
+ console.log(`Unable to decode cookie ${cookieKey}: ${e}`);
94
+ decodedValue = cookieValue;
95
+ }
96
+ }
97
+ return [cookieKey, decodedValue];
98
+ }));
99
+ };
89
100
  const setCookie = (key, value, options) => {
90
101
  var _a;
91
102
  try {
package/index.js CHANGED
@@ -65,28 +65,39 @@ var ProvidersBlotoutWalletSdk = (function () {
65
65
  const cartTokenLinkCookie = 'bwCartLinkToken';
66
66
 
67
67
  const getCookieValue = (key) => {
68
+ var _a;
68
69
  try {
69
70
  if (!document || !document.cookie) {
70
71
  return '';
71
72
  }
72
- const name = `${key}=`;
73
- const decodedCookie = decodeURIComponent(document.cookie);
74
- const ca = decodedCookie.split(';');
75
- for (let i = 0; i < ca.length; i++) {
76
- let c = ca[i];
77
- while (c.charAt(0) === ' ') {
78
- c = c.substring(1);
79
- }
80
- if (c.indexOf(name) === 0) {
81
- return c.substring(name.length, c.length);
82
- }
83
- }
84
- return '';
73
+ const cookies = parseCookies(document.cookie);
74
+ return (_a = cookies[key]) !== null && _a !== void 0 ? _a : '';
85
75
  }
86
76
  catch {
87
77
  return '';
88
78
  }
89
79
  };
80
+ const parseCookies = (cookie) => {
81
+ return Object.fromEntries(cookie
82
+ .split(/;\s+/)
83
+ .map((r) => r.split('=').map((str) => str.trim()))
84
+ .map(([cookieKey, cookieValue]) => {
85
+ if (!cookieKey) {
86
+ return [];
87
+ }
88
+ let decodedValue = '';
89
+ if (cookieValue) {
90
+ try {
91
+ decodedValue = decodeURIComponent(cookieValue);
92
+ }
93
+ catch (e) {
94
+ console.log(`Unable to decode cookie ${cookieKey}: ${e}`);
95
+ decodedValue = cookieValue;
96
+ }
97
+ }
98
+ return [cookieKey, decodedValue];
99
+ }));
100
+ };
90
101
  const setCookie = (key, value, options) => {
91
102
  var _a;
92
103
  try {
package/index.mjs CHANGED
@@ -62,28 +62,39 @@ const cartTokenTwoCookie = 'cart2';
62
62
  const cartTokenLinkCookie = 'bwCartLinkToken';
63
63
 
64
64
  const getCookieValue = (key) => {
65
+ var _a;
65
66
  try {
66
67
  if (!document || !document.cookie) {
67
68
  return '';
68
69
  }
69
- const name = `${key}=`;
70
- const decodedCookie = decodeURIComponent(document.cookie);
71
- const ca = decodedCookie.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);
76
- }
77
- if (c.indexOf(name) === 0) {
78
- return c.substring(name.length, c.length);
79
- }
80
- }
81
- return '';
70
+ const cookies = parseCookies(document.cookie);
71
+ return (_a = cookies[key]) !== null && _a !== void 0 ? _a : '';
82
72
  }
83
73
  catch {
84
74
  return '';
85
75
  }
86
76
  };
77
+ const parseCookies = (cookie) => {
78
+ return Object.fromEntries(cookie
79
+ .split(/;\s+/)
80
+ .map((r) => r.split('=').map((str) => str.trim()))
81
+ .map(([cookieKey, cookieValue]) => {
82
+ if (!cookieKey) {
83
+ return [];
84
+ }
85
+ let decodedValue = '';
86
+ if (cookieValue) {
87
+ try {
88
+ decodedValue = decodeURIComponent(cookieValue);
89
+ }
90
+ catch (e) {
91
+ console.log(`Unable to decode cookie ${cookieKey}: ${e}`);
92
+ decodedValue = cookieValue;
93
+ }
94
+ }
95
+ return [cookieKey, decodedValue];
96
+ }));
97
+ };
87
98
  const setCookie = (key, value, options) => {
88
99
  var _a;
89
100
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blotoutio/providers-blotout-wallet-sdk",
3
- "version": "0.60.0",
3
+ "version": "0.61.0",
4
4
  "description": "Blotout Wallet SDK for EdgeTag",
5
5
  "author": "Blotout",
6
6
  "license": "MIT",
@@ -42,28 +42,39 @@ const registryKey = Symbol.for('blotout-wallet');
42
42
  (_a = window[registryKey]) !== null && _a !== void 0 ? _a : (window[registryKey] = {});
43
43
 
44
44
  const getCookieValue = (key) => {
45
+ var _a;
45
46
  try {
46
47
  if (!document || !document.cookie) {
47
48
  return '';
48
49
  }
49
- const name = `${key}=`;
50
- const decodedCookie = decodeURIComponent(document.cookie);
51
- const ca = decodedCookie.split(';');
52
- for (let i = 0; i < ca.length; i++) {
53
- let c = ca[i];
54
- while (c.charAt(0) === ' ') {
55
- c = c.substring(1);
56
- }
57
- if (c.indexOf(name) === 0) {
58
- return c.substring(name.length, c.length);
59
- }
60
- }
61
- return '';
50
+ const cookies = parseCookies(document.cookie);
51
+ return (_a = cookies[key]) !== null && _a !== void 0 ? _a : '';
62
52
  }
63
53
  catch {
64
54
  return '';
65
55
  }
66
56
  };
57
+ const parseCookies = (cookie) => {
58
+ return Object.fromEntries(cookie
59
+ .split(/;\s+/)
60
+ .map((r) => r.split('=').map((str) => str.trim()))
61
+ .map(([cookieKey, cookieValue]) => {
62
+ if (!cookieKey) {
63
+ return [];
64
+ }
65
+ let decodedValue = '';
66
+ if (cookieValue) {
67
+ try {
68
+ decodedValue = decodeURIComponent(cookieValue);
69
+ }
70
+ catch (e) {
71
+ console.log(`Unable to decode cookie ${cookieKey}: ${e}`);
72
+ decodedValue = cookieValue;
73
+ }
74
+ }
75
+ return [cookieKey, decodedValue];
76
+ }));
77
+ };
67
78
 
68
79
  // eslint-disable-next-line @nx/enforce-module-boundaries
69
80
  const createShopApi = (fetchOverride = window.fetch) => ({
@@ -43,28 +43,39 @@
43
43
  (_a = window[registryKey]) !== null && _a !== void 0 ? _a : (window[registryKey] = {});
44
44
 
45
45
  const getCookieValue = (key) => {
46
+ var _a;
46
47
  try {
47
48
  if (!document || !document.cookie) {
48
49
  return '';
49
50
  }
50
- const name = `${key}=`;
51
- const decodedCookie = decodeURIComponent(document.cookie);
52
- const ca = decodedCookie.split(';');
53
- for (let i = 0; i < ca.length; i++) {
54
- let c = ca[i];
55
- while (c.charAt(0) === ' ') {
56
- c = c.substring(1);
57
- }
58
- if (c.indexOf(name) === 0) {
59
- return c.substring(name.length, c.length);
60
- }
61
- }
62
- return '';
51
+ const cookies = parseCookies(document.cookie);
52
+ return (_a = cookies[key]) !== null && _a !== void 0 ? _a : '';
63
53
  }
64
54
  catch {
65
55
  return '';
66
56
  }
67
57
  };
58
+ const parseCookies = (cookie) => {
59
+ return Object.fromEntries(cookie
60
+ .split(/;\s+/)
61
+ .map((r) => r.split('=').map((str) => str.trim()))
62
+ .map(([cookieKey, cookieValue]) => {
63
+ if (!cookieKey) {
64
+ return [];
65
+ }
66
+ let decodedValue = '';
67
+ if (cookieValue) {
68
+ try {
69
+ decodedValue = decodeURIComponent(cookieValue);
70
+ }
71
+ catch (e) {
72
+ console.log(`Unable to decode cookie ${cookieKey}: ${e}`);
73
+ decodedValue = cookieValue;
74
+ }
75
+ }
76
+ return [cookieKey, decodedValue];
77
+ }));
78
+ };
68
79
 
69
80
  // eslint-disable-next-line @nx/enforce-module-boundaries
70
81
  const createShopApi = (fetchOverride = window.fetch) => ({
@@ -40,28 +40,39 @@ const registryKey = Symbol.for('blotout-wallet');
40
40
  (_a = window[registryKey]) !== null && _a !== void 0 ? _a : (window[registryKey] = {});
41
41
 
42
42
  const getCookieValue = (key) => {
43
+ var _a;
43
44
  try {
44
45
  if (!document || !document.cookie) {
45
46
  return '';
46
47
  }
47
- const name = `${key}=`;
48
- const decodedCookie = decodeURIComponent(document.cookie);
49
- const ca = decodedCookie.split(';');
50
- for (let i = 0; i < ca.length; i++) {
51
- let c = ca[i];
52
- while (c.charAt(0) === ' ') {
53
- c = c.substring(1);
54
- }
55
- if (c.indexOf(name) === 0) {
56
- return c.substring(name.length, c.length);
57
- }
58
- }
59
- return '';
48
+ const cookies = parseCookies(document.cookie);
49
+ return (_a = cookies[key]) !== null && _a !== void 0 ? _a : '';
60
50
  }
61
51
  catch {
62
52
  return '';
63
53
  }
64
54
  };
55
+ const parseCookies = (cookie) => {
56
+ return Object.fromEntries(cookie
57
+ .split(/;\s+/)
58
+ .map((r) => r.split('=').map((str) => str.trim()))
59
+ .map(([cookieKey, cookieValue]) => {
60
+ if (!cookieKey) {
61
+ return [];
62
+ }
63
+ let decodedValue = '';
64
+ if (cookieValue) {
65
+ try {
66
+ decodedValue = decodeURIComponent(cookieValue);
67
+ }
68
+ catch (e) {
69
+ console.log(`Unable to decode cookie ${cookieKey}: ${e}`);
70
+ decodedValue = cookieValue;
71
+ }
72
+ }
73
+ return [cookieKey, decodedValue];
74
+ }));
75
+ };
65
76
 
66
77
  // eslint-disable-next-line @nx/enforce-module-boundaries
67
78
  const createShopApi = (fetchOverride = window.fetch) => ({