@blotoutio/providers-blotout-wallet-sdk 0.55.0 → 0.55.1
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 +19 -13
- package/index.js +19 -13
- package/index.mjs +19 -13
- package/package.json +1 -1
- package/stores/shopify/index.cjs.js +1 -3
- package/stores/shopify/index.js +1 -3
- package/stores/shopify/index.mjs +1 -3
package/index.cjs.js
CHANGED
@@ -59,7 +59,6 @@ const customAttributes = {
|
|
59
59
|
const packageName = 'blotoutWallet';
|
60
60
|
const cartTokenCookie = 'cart';
|
61
61
|
const cartTokenTwoCookie = 'cart2';
|
62
|
-
const cartCurrencyCookie = 'cart_currency';
|
63
62
|
const cartTokenLinkCookie = 'bwCartLinkToken';
|
64
63
|
|
65
64
|
const getCookieValue = (key) => {
|
@@ -168,7 +167,6 @@ const tag = ({ eventName }) => {
|
|
168
167
|
switch (platform) {
|
169
168
|
case 'SHOPIFY': {
|
170
169
|
let cartToken = getCookieValue(cartTokenCookie);
|
171
|
-
const cartCurrency = getCookieValue(cartCurrencyCookie);
|
172
170
|
const cartTokenLink = getCookieValue(cartTokenLinkCookie);
|
173
171
|
if (!cartToken) {
|
174
172
|
cartToken = getCookieValue(cartTokenTwoCookie);
|
@@ -179,7 +177,7 @@ const tag = ({ eventName }) => {
|
|
179
177
|
if (cartTokenLink) {
|
180
178
|
setCookie(cartTokenLinkCookie, '', { maxAge: 0 });
|
181
179
|
}
|
182
|
-
return { cartToken,
|
180
|
+
return { cartToken, cartTokenLink };
|
183
181
|
}
|
184
182
|
default: {
|
185
183
|
return {};
|
@@ -480,6 +478,16 @@ let BlotoutWallet = class BlotoutWallet extends s {
|
|
480
478
|
if (!response.ok) {
|
481
479
|
throw new Error(`Could not update status in DB - ${response.status}: ${response.text}\n\n${await response.text()}`);
|
482
480
|
}
|
481
|
+
// Redirect to custom path
|
482
|
+
if (this.restoreRedirect) {
|
483
|
+
try {
|
484
|
+
const redirect = new URL(this.restoreRedirect, window.location.origin);
|
485
|
+
window.location.href = redirect.href;
|
486
|
+
}
|
487
|
+
catch (e) {
|
488
|
+
console.error('Invalid redirect URL', e);
|
489
|
+
}
|
490
|
+
}
|
483
491
|
})
|
484
492
|
.catch((err) => {
|
485
493
|
console.error(err);
|
@@ -513,11 +521,8 @@ let BlotoutWallet = class BlotoutWallet extends s {
|
|
513
521
|
};
|
514
522
|
this.expiredCartContent = () => {
|
515
523
|
var _a, _b, _c, _d;
|
516
|
-
return x
|
517
|
-
|
518
|
-
method="dialog"
|
519
|
-
@submit=${this.onSubmit}
|
520
|
-
>
|
524
|
+
return x `
|
525
|
+
<form class="restore-form" method="dialog" @submit=${this.onSubmit}>
|
521
526
|
<div>
|
522
527
|
${formatString(((_a = this.theme) === null || _a === void 0 ? void 0 : _a.text) || customAttributes.text.defaultValue)}
|
523
528
|
</div>
|
@@ -539,7 +544,8 @@ let BlotoutWallet = class BlotoutWallet extends s {
|
|
539
544
|
<button class="delete" type="button" @click=${this.skipCarts}>
|
540
545
|
${((_d = this.theme) === null || _d === void 0 ? void 0 : _d.rejectionLabel) ||
|
541
546
|
customAttributes.rejectionLabel.defaultValue}
|
542
|
-
</button>
|
547
|
+
</button>
|
548
|
+
`;
|
543
549
|
};
|
544
550
|
this.loadingContent = () => {
|
545
551
|
return x `
|
@@ -634,8 +640,7 @@ let BlotoutWallet = class BlotoutWallet extends s {
|
|
634
640
|
getUrl(path) {
|
635
641
|
const url = new URL(`/providers/blotoutWallet${path}`, this.edgeURL);
|
636
642
|
if (this.storeApi) {
|
637
|
-
const { cartToken
|
638
|
-
url.searchParams.set('c', cartCurrency);
|
643
|
+
const { cartToken } = this.storeApi.getCartInfo();
|
639
644
|
url.searchParams.set('t', cartToken);
|
640
645
|
}
|
641
646
|
return url;
|
@@ -658,7 +663,7 @@ let BlotoutWallet = class BlotoutWallet extends s {
|
|
658
663
|
if (this.isPopUpDismissed) {
|
659
664
|
return T;
|
660
665
|
}
|
661
|
-
return x
|
666
|
+
return x ` <dialog @click=${this.onDialogClick}>
|
662
667
|
<div @click=${this.onWrapperClick}>
|
663
668
|
<div
|
664
669
|
class="centered"
|
@@ -813,7 +818,7 @@ BlotoutWallet = __decorate([
|
|
813
818
|
], BlotoutWallet);
|
814
819
|
|
815
820
|
const init = (params) => {
|
816
|
-
var _a, _b, _c, _d;
|
821
|
+
var _a, _b, _c, _d, _e;
|
817
822
|
if (
|
818
823
|
// if loaded in non-browser SDKs
|
819
824
|
!window ||
|
@@ -842,6 +847,7 @@ const init = (params) => {
|
|
842
847
|
element.theme = theme;
|
843
848
|
element.edgeURL = params.baseUrl;
|
844
849
|
element.userId = params.userId;
|
850
|
+
element.restoreRedirect = (_e = params.manifest.variables) === null || _e === void 0 ? void 0 : _e['restoreRedirect'];
|
845
851
|
document.body.append(element);
|
846
852
|
}
|
847
853
|
};
|
package/index.js
CHANGED
@@ -60,7 +60,6 @@ var ProvidersBlotoutWalletSdk = (function () {
|
|
60
60
|
const packageName = 'blotoutWallet';
|
61
61
|
const cartTokenCookie = 'cart';
|
62
62
|
const cartTokenTwoCookie = 'cart2';
|
63
|
-
const cartCurrencyCookie = 'cart_currency';
|
64
63
|
const cartTokenLinkCookie = 'bwCartLinkToken';
|
65
64
|
|
66
65
|
const getCookieValue = (key) => {
|
@@ -169,7 +168,6 @@ var ProvidersBlotoutWalletSdk = (function () {
|
|
169
168
|
switch (platform) {
|
170
169
|
case 'SHOPIFY': {
|
171
170
|
let cartToken = getCookieValue(cartTokenCookie);
|
172
|
-
const cartCurrency = getCookieValue(cartCurrencyCookie);
|
173
171
|
const cartTokenLink = getCookieValue(cartTokenLinkCookie);
|
174
172
|
if (!cartToken) {
|
175
173
|
cartToken = getCookieValue(cartTokenTwoCookie);
|
@@ -180,7 +178,7 @@ var ProvidersBlotoutWalletSdk = (function () {
|
|
180
178
|
if (cartTokenLink) {
|
181
179
|
setCookie(cartTokenLinkCookie, '', { maxAge: 0 });
|
182
180
|
}
|
183
|
-
return { cartToken,
|
181
|
+
return { cartToken, cartTokenLink };
|
184
182
|
}
|
185
183
|
default: {
|
186
184
|
return {};
|
@@ -481,6 +479,16 @@ var ProvidersBlotoutWalletSdk = (function () {
|
|
481
479
|
if (!response.ok) {
|
482
480
|
throw new Error(`Could not update status in DB - ${response.status}: ${response.text}\n\n${await response.text()}`);
|
483
481
|
}
|
482
|
+
// Redirect to custom path
|
483
|
+
if (this.restoreRedirect) {
|
484
|
+
try {
|
485
|
+
const redirect = new URL(this.restoreRedirect, window.location.origin);
|
486
|
+
window.location.href = redirect.href;
|
487
|
+
}
|
488
|
+
catch (e) {
|
489
|
+
console.error('Invalid redirect URL', e);
|
490
|
+
}
|
491
|
+
}
|
484
492
|
})
|
485
493
|
.catch((err) => {
|
486
494
|
console.error(err);
|
@@ -514,11 +522,8 @@ var ProvidersBlotoutWalletSdk = (function () {
|
|
514
522
|
};
|
515
523
|
this.expiredCartContent = () => {
|
516
524
|
var _a, _b, _c, _d;
|
517
|
-
return x
|
518
|
-
|
519
|
-
method="dialog"
|
520
|
-
@submit=${this.onSubmit}
|
521
|
-
>
|
525
|
+
return x `
|
526
|
+
<form class="restore-form" method="dialog" @submit=${this.onSubmit}>
|
522
527
|
<div>
|
523
528
|
${formatString(((_a = this.theme) === null || _a === void 0 ? void 0 : _a.text) || customAttributes.text.defaultValue)}
|
524
529
|
</div>
|
@@ -540,7 +545,8 @@ var ProvidersBlotoutWalletSdk = (function () {
|
|
540
545
|
<button class="delete" type="button" @click=${this.skipCarts}>
|
541
546
|
${((_d = this.theme) === null || _d === void 0 ? void 0 : _d.rejectionLabel) ||
|
542
547
|
customAttributes.rejectionLabel.defaultValue}
|
543
|
-
</button>
|
548
|
+
</button>
|
549
|
+
`;
|
544
550
|
};
|
545
551
|
this.loadingContent = () => {
|
546
552
|
return x `
|
@@ -635,8 +641,7 @@ var ProvidersBlotoutWalletSdk = (function () {
|
|
635
641
|
getUrl(path) {
|
636
642
|
const url = new URL(`/providers/blotoutWallet${path}`, this.edgeURL);
|
637
643
|
if (this.storeApi) {
|
638
|
-
const { cartToken
|
639
|
-
url.searchParams.set('c', cartCurrency);
|
644
|
+
const { cartToken } = this.storeApi.getCartInfo();
|
640
645
|
url.searchParams.set('t', cartToken);
|
641
646
|
}
|
642
647
|
return url;
|
@@ -659,7 +664,7 @@ var ProvidersBlotoutWalletSdk = (function () {
|
|
659
664
|
if (this.isPopUpDismissed) {
|
660
665
|
return T;
|
661
666
|
}
|
662
|
-
return x
|
667
|
+
return x ` <dialog @click=${this.onDialogClick}>
|
663
668
|
<div @click=${this.onWrapperClick}>
|
664
669
|
<div
|
665
670
|
class="centered"
|
@@ -814,7 +819,7 @@ var ProvidersBlotoutWalletSdk = (function () {
|
|
814
819
|
], BlotoutWallet);
|
815
820
|
|
816
821
|
const init = (params) => {
|
817
|
-
var _a, _b, _c, _d;
|
822
|
+
var _a, _b, _c, _d, _e;
|
818
823
|
if (
|
819
824
|
// if loaded in non-browser SDKs
|
820
825
|
!window ||
|
@@ -843,6 +848,7 @@ var ProvidersBlotoutWalletSdk = (function () {
|
|
843
848
|
element.theme = theme;
|
844
849
|
element.edgeURL = params.baseUrl;
|
845
850
|
element.userId = params.userId;
|
851
|
+
element.restoreRedirect = (_e = params.manifest.variables) === null || _e === void 0 ? void 0 : _e['restoreRedirect'];
|
846
852
|
document.body.append(element);
|
847
853
|
}
|
848
854
|
};
|
package/index.mjs
CHANGED
@@ -57,7 +57,6 @@ const customAttributes = {
|
|
57
57
|
const packageName = 'blotoutWallet';
|
58
58
|
const cartTokenCookie = 'cart';
|
59
59
|
const cartTokenTwoCookie = 'cart2';
|
60
|
-
const cartCurrencyCookie = 'cart_currency';
|
61
60
|
const cartTokenLinkCookie = 'bwCartLinkToken';
|
62
61
|
|
63
62
|
const getCookieValue = (key) => {
|
@@ -166,7 +165,6 @@ const tag = ({ eventName }) => {
|
|
166
165
|
switch (platform) {
|
167
166
|
case 'SHOPIFY': {
|
168
167
|
let cartToken = getCookieValue(cartTokenCookie);
|
169
|
-
const cartCurrency = getCookieValue(cartCurrencyCookie);
|
170
168
|
const cartTokenLink = getCookieValue(cartTokenLinkCookie);
|
171
169
|
if (!cartToken) {
|
172
170
|
cartToken = getCookieValue(cartTokenTwoCookie);
|
@@ -177,7 +175,7 @@ const tag = ({ eventName }) => {
|
|
177
175
|
if (cartTokenLink) {
|
178
176
|
setCookie(cartTokenLinkCookie, '', { maxAge: 0 });
|
179
177
|
}
|
180
|
-
return { cartToken,
|
178
|
+
return { cartToken, cartTokenLink };
|
181
179
|
}
|
182
180
|
default: {
|
183
181
|
return {};
|
@@ -478,6 +476,16 @@ let BlotoutWallet = class BlotoutWallet extends s {
|
|
478
476
|
if (!response.ok) {
|
479
477
|
throw new Error(`Could not update status in DB - ${response.status}: ${response.text}\n\n${await response.text()}`);
|
480
478
|
}
|
479
|
+
// Redirect to custom path
|
480
|
+
if (this.restoreRedirect) {
|
481
|
+
try {
|
482
|
+
const redirect = new URL(this.restoreRedirect, window.location.origin);
|
483
|
+
window.location.href = redirect.href;
|
484
|
+
}
|
485
|
+
catch (e) {
|
486
|
+
console.error('Invalid redirect URL', e);
|
487
|
+
}
|
488
|
+
}
|
481
489
|
})
|
482
490
|
.catch((err) => {
|
483
491
|
console.error(err);
|
@@ -511,11 +519,8 @@ let BlotoutWallet = class BlotoutWallet extends s {
|
|
511
519
|
};
|
512
520
|
this.expiredCartContent = () => {
|
513
521
|
var _a, _b, _c, _d;
|
514
|
-
return x
|
515
|
-
|
516
|
-
method="dialog"
|
517
|
-
@submit=${this.onSubmit}
|
518
|
-
>
|
522
|
+
return x `
|
523
|
+
<form class="restore-form" method="dialog" @submit=${this.onSubmit}>
|
519
524
|
<div>
|
520
525
|
${formatString(((_a = this.theme) === null || _a === void 0 ? void 0 : _a.text) || customAttributes.text.defaultValue)}
|
521
526
|
</div>
|
@@ -537,7 +542,8 @@ let BlotoutWallet = class BlotoutWallet extends s {
|
|
537
542
|
<button class="delete" type="button" @click=${this.skipCarts}>
|
538
543
|
${((_d = this.theme) === null || _d === void 0 ? void 0 : _d.rejectionLabel) ||
|
539
544
|
customAttributes.rejectionLabel.defaultValue}
|
540
|
-
</button>
|
545
|
+
</button>
|
546
|
+
`;
|
541
547
|
};
|
542
548
|
this.loadingContent = () => {
|
543
549
|
return x `
|
@@ -632,8 +638,7 @@ let BlotoutWallet = class BlotoutWallet extends s {
|
|
632
638
|
getUrl(path) {
|
633
639
|
const url = new URL(`/providers/blotoutWallet${path}`, this.edgeURL);
|
634
640
|
if (this.storeApi) {
|
635
|
-
const { cartToken
|
636
|
-
url.searchParams.set('c', cartCurrency);
|
641
|
+
const { cartToken } = this.storeApi.getCartInfo();
|
637
642
|
url.searchParams.set('t', cartToken);
|
638
643
|
}
|
639
644
|
return url;
|
@@ -656,7 +661,7 @@ let BlotoutWallet = class BlotoutWallet extends s {
|
|
656
661
|
if (this.isPopUpDismissed) {
|
657
662
|
return T;
|
658
663
|
}
|
659
|
-
return x
|
664
|
+
return x ` <dialog @click=${this.onDialogClick}>
|
660
665
|
<div @click=${this.onWrapperClick}>
|
661
666
|
<div
|
662
667
|
class="centered"
|
@@ -811,7 +816,7 @@ BlotoutWallet = __decorate([
|
|
811
816
|
], BlotoutWallet);
|
812
817
|
|
813
818
|
const init = (params) => {
|
814
|
-
var _a, _b, _c, _d;
|
819
|
+
var _a, _b, _c, _d, _e;
|
815
820
|
if (
|
816
821
|
// if loaded in non-browser SDKs
|
817
822
|
!window ||
|
@@ -840,6 +845,7 @@ const init = (params) => {
|
|
840
845
|
element.theme = theme;
|
841
846
|
element.edgeURL = params.baseUrl;
|
842
847
|
element.userId = params.userId;
|
848
|
+
element.restoreRedirect = (_e = params.manifest.variables) === null || _e === void 0 ? void 0 : _e['restoreRedirect'];
|
843
849
|
document.body.append(element);
|
844
850
|
}
|
845
851
|
};
|
package/package.json
CHANGED
@@ -36,7 +36,6 @@ new Set([
|
|
36
36
|
|
37
37
|
const cartTokenCookie = 'cart';
|
38
38
|
const cartTokenTwoCookie = 'cart2';
|
39
|
-
const cartCurrencyCookie = 'cart_currency';
|
40
39
|
|
41
40
|
var _a;
|
42
41
|
const registryKey = Symbol.for('blotout-wallet');
|
@@ -120,11 +119,10 @@ const createShopApi = (fetchOverride = window.fetch) => ({
|
|
120
119
|
// duplicated this on tag call, as this was not being set before tag call gets initiated
|
121
120
|
getCartInfo() {
|
122
121
|
let cartToken = getCookieValue(cartTokenCookie);
|
123
|
-
const cartCurrency = getCookieValue(cartCurrencyCookie);
|
124
122
|
if (!cartToken) {
|
125
123
|
cartToken = getCookieValue(cartTokenTwoCookie);
|
126
124
|
}
|
127
|
-
return { cartToken
|
125
|
+
return { cartToken };
|
128
126
|
},
|
129
127
|
});
|
130
128
|
window[registryKey].storeAPIFactory = createShopApi;
|
package/stores/shopify/index.js
CHANGED
@@ -37,7 +37,6 @@
|
|
37
37
|
|
38
38
|
const cartTokenCookie = 'cart';
|
39
39
|
const cartTokenTwoCookie = 'cart2';
|
40
|
-
const cartCurrencyCookie = 'cart_currency';
|
41
40
|
|
42
41
|
var _a;
|
43
42
|
const registryKey = Symbol.for('blotout-wallet');
|
@@ -121,11 +120,10 @@
|
|
121
120
|
// duplicated this on tag call, as this was not being set before tag call gets initiated
|
122
121
|
getCartInfo() {
|
123
122
|
let cartToken = getCookieValue(cartTokenCookie);
|
124
|
-
const cartCurrency = getCookieValue(cartCurrencyCookie);
|
125
123
|
if (!cartToken) {
|
126
124
|
cartToken = getCookieValue(cartTokenTwoCookie);
|
127
125
|
}
|
128
|
-
return { cartToken
|
126
|
+
return { cartToken };
|
129
127
|
},
|
130
128
|
});
|
131
129
|
window[registryKey].storeAPIFactory = createShopApi;
|
package/stores/shopify/index.mjs
CHANGED
@@ -34,7 +34,6 @@ new Set([
|
|
34
34
|
|
35
35
|
const cartTokenCookie = 'cart';
|
36
36
|
const cartTokenTwoCookie = 'cart2';
|
37
|
-
const cartCurrencyCookie = 'cart_currency';
|
38
37
|
|
39
38
|
var _a;
|
40
39
|
const registryKey = Symbol.for('blotout-wallet');
|
@@ -118,11 +117,10 @@ const createShopApi = (fetchOverride = window.fetch) => ({
|
|
118
117
|
// duplicated this on tag call, as this was not being set before tag call gets initiated
|
119
118
|
getCartInfo() {
|
120
119
|
let cartToken = getCookieValue(cartTokenCookie);
|
121
|
-
const cartCurrency = getCookieValue(cartCurrencyCookie);
|
122
120
|
if (!cartToken) {
|
123
121
|
cartToken = getCookieValue(cartTokenTwoCookie);
|
124
122
|
}
|
125
|
-
return { cartToken
|
123
|
+
return { cartToken };
|
126
124
|
},
|
127
125
|
});
|
128
126
|
window[registryKey].storeAPIFactory = createShopApi;
|