@blotoutio/providers-blotout-wallet-sdk 1.12.1 → 1.14.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/core.cjs.js +5 -0
- package/core.js +5 -0
- package/core.mjs +5 -0
- package/index.cjs.js +32 -30
- package/index.js +32 -30
- package/index.mjs +32 -30
- package/package.json +3 -1
- package/ui.cjs.js +27 -30
- package/ui.js +27 -30
- package/ui.mjs +27 -30
package/core.cjs.js
CHANGED
@@ -593,6 +593,7 @@ const createWalletAPI = ({ fetch: fetchImpl = window.fetch, baseURL, userId, sto
|
|
593
593
|
const response = await fetchImpl(getURL('/cart/expired'), {
|
594
594
|
method: 'GET',
|
595
595
|
headers: getHeaders(),
|
596
|
+
credentials: 'include',
|
596
597
|
});
|
597
598
|
if (!response.ok) {
|
598
599
|
throw new Error(`Unable to get expired cart - ${response.status}: ${response.statusText}\n\n${await response.text()}`);
|
@@ -613,6 +614,7 @@ const createWalletAPI = ({ fetch: fetchImpl = window.fetch, baseURL, userId, sto
|
|
613
614
|
method: 'POST',
|
614
615
|
headers: getHeaders(true),
|
615
616
|
body: JSON.stringify({ action }),
|
617
|
+
credentials: 'include',
|
616
618
|
});
|
617
619
|
if (!response.ok) {
|
618
620
|
throw new Error(`Error while recording user event - ${response.status}: ${response.statusText}\n\n${await response.text()}`);
|
@@ -628,6 +630,7 @@ const createWalletAPI = ({ fetch: fetchImpl = window.fetch, baseURL, userId, sto
|
|
628
630
|
method: 'POST',
|
629
631
|
headers: getHeaders(true),
|
630
632
|
body: JSON.stringify({ email: normalized }),
|
633
|
+
credentials: 'include',
|
631
634
|
});
|
632
635
|
if (!response.ok) {
|
633
636
|
throw new Error(`Could not save email - ${response.status}: ${response.statusText}\n\n${await response.text()}`);
|
@@ -638,6 +641,7 @@ const createWalletAPI = ({ fetch: fetchImpl = window.fetch, baseURL, userId, sto
|
|
638
641
|
const response = await fetchImpl(getURL(`/cart/restore/${encodeURIComponent(cartId)}`), {
|
639
642
|
method: 'POST',
|
640
643
|
headers: getHeaders(),
|
644
|
+
credentials: 'include',
|
641
645
|
});
|
642
646
|
if (!response.ok) {
|
643
647
|
throw new Error(`Could not update status in DB - ${response.status}: ${response.text}\n\n${await response.text()}`);
|
@@ -650,6 +654,7 @@ const createWalletAPI = ({ fetch: fetchImpl = window.fetch, baseURL, userId, sto
|
|
650
654
|
const response = await fetchImpl(getURL('/cart/skip'), {
|
651
655
|
method: 'POST',
|
652
656
|
headers: getHeaders(),
|
657
|
+
credentials: 'include',
|
653
658
|
});
|
654
659
|
if (!response.ok) {
|
655
660
|
throw new Error(`Could not mark cart as skipped - ${response.status}: ${await response.text()}`);
|
package/core.js
CHANGED
@@ -594,6 +594,7 @@ var ProvidersBlotoutWalletSdk = (function () {
|
|
594
594
|
const response = await fetchImpl(getURL('/cart/expired'), {
|
595
595
|
method: 'GET',
|
596
596
|
headers: getHeaders(),
|
597
|
+
credentials: 'include',
|
597
598
|
});
|
598
599
|
if (!response.ok) {
|
599
600
|
throw new Error(`Unable to get expired cart - ${response.status}: ${response.statusText}\n\n${await response.text()}`);
|
@@ -614,6 +615,7 @@ var ProvidersBlotoutWalletSdk = (function () {
|
|
614
615
|
method: 'POST',
|
615
616
|
headers: getHeaders(true),
|
616
617
|
body: JSON.stringify({ action }),
|
618
|
+
credentials: 'include',
|
617
619
|
});
|
618
620
|
if (!response.ok) {
|
619
621
|
throw new Error(`Error while recording user event - ${response.status}: ${response.statusText}\n\n${await response.text()}`);
|
@@ -629,6 +631,7 @@ var ProvidersBlotoutWalletSdk = (function () {
|
|
629
631
|
method: 'POST',
|
630
632
|
headers: getHeaders(true),
|
631
633
|
body: JSON.stringify({ email: normalized }),
|
634
|
+
credentials: 'include',
|
632
635
|
});
|
633
636
|
if (!response.ok) {
|
634
637
|
throw new Error(`Could not save email - ${response.status}: ${response.statusText}\n\n${await response.text()}`);
|
@@ -639,6 +642,7 @@ var ProvidersBlotoutWalletSdk = (function () {
|
|
639
642
|
const response = await fetchImpl(getURL(`/cart/restore/${encodeURIComponent(cartId)}`), {
|
640
643
|
method: 'POST',
|
641
644
|
headers: getHeaders(),
|
645
|
+
credentials: 'include',
|
642
646
|
});
|
643
647
|
if (!response.ok) {
|
644
648
|
throw new Error(`Could not update status in DB - ${response.status}: ${response.text}\n\n${await response.text()}`);
|
@@ -651,6 +655,7 @@ var ProvidersBlotoutWalletSdk = (function () {
|
|
651
655
|
const response = await fetchImpl(getURL('/cart/skip'), {
|
652
656
|
method: 'POST',
|
653
657
|
headers: getHeaders(),
|
658
|
+
credentials: 'include',
|
654
659
|
});
|
655
660
|
if (!response.ok) {
|
656
661
|
throw new Error(`Could not mark cart as skipped - ${response.status}: ${await response.text()}`);
|
package/core.mjs
CHANGED
@@ -591,6 +591,7 @@ const createWalletAPI = ({ fetch: fetchImpl = window.fetch, baseURL, userId, sto
|
|
591
591
|
const response = await fetchImpl(getURL('/cart/expired'), {
|
592
592
|
method: 'GET',
|
593
593
|
headers: getHeaders(),
|
594
|
+
credentials: 'include',
|
594
595
|
});
|
595
596
|
if (!response.ok) {
|
596
597
|
throw new Error(`Unable to get expired cart - ${response.status}: ${response.statusText}\n\n${await response.text()}`);
|
@@ -611,6 +612,7 @@ const createWalletAPI = ({ fetch: fetchImpl = window.fetch, baseURL, userId, sto
|
|
611
612
|
method: 'POST',
|
612
613
|
headers: getHeaders(true),
|
613
614
|
body: JSON.stringify({ action }),
|
615
|
+
credentials: 'include',
|
614
616
|
});
|
615
617
|
if (!response.ok) {
|
616
618
|
throw new Error(`Error while recording user event - ${response.status}: ${response.statusText}\n\n${await response.text()}`);
|
@@ -626,6 +628,7 @@ const createWalletAPI = ({ fetch: fetchImpl = window.fetch, baseURL, userId, sto
|
|
626
628
|
method: 'POST',
|
627
629
|
headers: getHeaders(true),
|
628
630
|
body: JSON.stringify({ email: normalized }),
|
631
|
+
credentials: 'include',
|
629
632
|
});
|
630
633
|
if (!response.ok) {
|
631
634
|
throw new Error(`Could not save email - ${response.status}: ${response.statusText}\n\n${await response.text()}`);
|
@@ -636,6 +639,7 @@ const createWalletAPI = ({ fetch: fetchImpl = window.fetch, baseURL, userId, sto
|
|
636
639
|
const response = await fetchImpl(getURL(`/cart/restore/${encodeURIComponent(cartId)}`), {
|
637
640
|
method: 'POST',
|
638
641
|
headers: getHeaders(),
|
642
|
+
credentials: 'include',
|
639
643
|
});
|
640
644
|
if (!response.ok) {
|
641
645
|
throw new Error(`Could not update status in DB - ${response.status}: ${response.text}\n\n${await response.text()}`);
|
@@ -648,6 +652,7 @@ const createWalletAPI = ({ fetch: fetchImpl = window.fetch, baseURL, userId, sto
|
|
648
652
|
const response = await fetchImpl(getURL('/cart/skip'), {
|
649
653
|
method: 'POST',
|
650
654
|
headers: getHeaders(),
|
655
|
+
credentials: 'include',
|
651
656
|
});
|
652
657
|
if (!response.ok) {
|
653
658
|
throw new Error(`Could not mark cart as skipped - ${response.status}: ${await response.text()}`);
|
package/index.cjs.js
CHANGED
@@ -686,6 +686,7 @@ const createWalletAPI = ({ fetch: fetchImpl = window.fetch, baseURL, userId, sto
|
|
686
686
|
const response = await fetchImpl(getURL('/cart/expired'), {
|
687
687
|
method: 'GET',
|
688
688
|
headers: getHeaders(),
|
689
|
+
credentials: 'include',
|
689
690
|
});
|
690
691
|
if (!response.ok) {
|
691
692
|
throw new Error(`Unable to get expired cart - ${response.status}: ${response.statusText}\n\n${await response.text()}`);
|
@@ -706,6 +707,7 @@ const createWalletAPI = ({ fetch: fetchImpl = window.fetch, baseURL, userId, sto
|
|
706
707
|
method: 'POST',
|
707
708
|
headers: getHeaders(true),
|
708
709
|
body: JSON.stringify({ action }),
|
710
|
+
credentials: 'include',
|
709
711
|
});
|
710
712
|
if (!response.ok) {
|
711
713
|
throw new Error(`Error while recording user event - ${response.status}: ${response.statusText}\n\n${await response.text()}`);
|
@@ -721,6 +723,7 @@ const createWalletAPI = ({ fetch: fetchImpl = window.fetch, baseURL, userId, sto
|
|
721
723
|
method: 'POST',
|
722
724
|
headers: getHeaders(true),
|
723
725
|
body: JSON.stringify({ email: normalized }),
|
726
|
+
credentials: 'include',
|
724
727
|
});
|
725
728
|
if (!response.ok) {
|
726
729
|
throw new Error(`Could not save email - ${response.status}: ${response.statusText}\n\n${await response.text()}`);
|
@@ -731,6 +734,7 @@ const createWalletAPI = ({ fetch: fetchImpl = window.fetch, baseURL, userId, sto
|
|
731
734
|
const response = await fetchImpl(getURL(`/cart/restore/${encodeURIComponent(cartId)}`), {
|
732
735
|
method: 'POST',
|
733
736
|
headers: getHeaders(),
|
737
|
+
credentials: 'include',
|
734
738
|
});
|
735
739
|
if (!response.ok) {
|
736
740
|
throw new Error(`Could not update status in DB - ${response.status}: ${response.text}\n\n${await response.text()}`);
|
@@ -743,6 +747,7 @@ const createWalletAPI = ({ fetch: fetchImpl = window.fetch, baseURL, userId, sto
|
|
743
747
|
const response = await fetchImpl(getURL('/cart/skip'), {
|
744
748
|
method: 'POST',
|
745
749
|
headers: getHeaders(),
|
750
|
+
credentials: 'include',
|
746
751
|
});
|
747
752
|
if (!response.ok) {
|
748
753
|
throw new Error(`Could not mark cart as skipped - ${response.status}: ${await response.text()}`);
|
@@ -1143,12 +1148,7 @@ let BlotoutWallet = class BlotoutWallet extends i$2 {
|
|
1143
1148
|
}
|
1144
1149
|
this.restoreResponse = await this.storeAPI.addItems(this.lastExpiredCart.items, this.lastExpiredCart.token);
|
1145
1150
|
const expiredCartId = this.lastExpiredCart.cartId;
|
1146
|
-
|
1147
|
-
// we log the error in the console and let the user continue. Since the
|
1148
|
-
// problem is probably in the `/cart/restore` endpoint, further attempts
|
1149
|
-
// would not resolve the problem, which would just increase the number
|
1150
|
-
// of failed calls and not solve the problem.
|
1151
|
-
await this.walletAPI.restoreCart(expiredCartId, this.silentRestore).catch(logger.error);
|
1151
|
+
await this.walletAPI.restoreCart(expiredCartId, this.silentRestore);
|
1152
1152
|
this.lastExpiredCart = undefined;
|
1153
1153
|
this.dispatchEvent(new CustomEvent('blotout-wallet-cart-restored', {
|
1154
1154
|
bubbles: true,
|
@@ -1165,35 +1165,37 @@ let BlotoutWallet = class BlotoutWallet extends i$2 {
|
|
1165
1165
|
if (this.state == 'restored') {
|
1166
1166
|
this.hideModal('restore');
|
1167
1167
|
}
|
1168
|
-
|
1169
|
-
|
1170
|
-
|
1171
|
-
|
1172
|
-
|
1173
|
-
|
1168
|
+
this.afterHandleRestore();
|
1169
|
+
}
|
1170
|
+
catch (e) {
|
1171
|
+
logger.error(e);
|
1172
|
+
await this.transitionTo('failed');
|
1173
|
+
}
|
1174
|
+
};
|
1175
|
+
this.afterHandleRestore = () => {
|
1176
|
+
if (this.afterRestore) {
|
1177
|
+
switch (this.afterRestore.action) {
|
1178
|
+
case 'refresh': {
|
1179
|
+
window.location.reload();
|
1180
|
+
break;
|
1181
|
+
}
|
1182
|
+
case 'redirect': {
|
1183
|
+
try {
|
1184
|
+
window.location.href = new URL(this.afterRestore.url, window.location.href).toString();
|
1174
1185
|
}
|
1175
|
-
|
1176
|
-
|
1177
|
-
window.location.href = new URL(this.afterRestore.url, window.location.href).toString();
|
1178
|
-
}
|
1179
|
-
catch (e) {
|
1180
|
-
console.error('Invalid redirect URL', e);
|
1181
|
-
}
|
1182
|
-
break;
|
1186
|
+
catch (e) {
|
1187
|
+
console.error('Invalid redirect URL', e);
|
1183
1188
|
}
|
1184
|
-
|
1185
|
-
|
1186
|
-
|
1187
|
-
|
1188
|
-
|
1189
|
+
break;
|
1190
|
+
}
|
1191
|
+
case 'checkout': {
|
1192
|
+
const url = this.storeAPI.getCheckoutURL();
|
1193
|
+
if (url) {
|
1194
|
+
window.location.href = url.toString();
|
1189
1195
|
}
|
1190
1196
|
}
|
1191
1197
|
}
|
1192
1198
|
}
|
1193
|
-
catch (e) {
|
1194
|
-
logger.error(e);
|
1195
|
-
await this.transitionTo('failed');
|
1196
|
-
}
|
1197
1199
|
};
|
1198
1200
|
this.onDialogClick = () => {
|
1199
1201
|
if (this.state == 'loading') {
|
@@ -1306,7 +1308,7 @@ let BlotoutWallet = class BlotoutWallet extends i$2 {
|
|
1306
1308
|
this.lastExpiredCart = carts[0];
|
1307
1309
|
if (carts === null || carts === void 0 ? void 0 : carts.length) {
|
1308
1310
|
if (this.silentRestore) {
|
1309
|
-
this.restoreCart().catch(logger.error);
|
1311
|
+
this.restoreCart().then(this.afterHandleRestore).catch(logger.error);
|
1310
1312
|
}
|
1311
1313
|
else if (!this.isPopUpDismissed) {
|
1312
1314
|
this.showModal();
|
package/index.js
CHANGED
@@ -687,6 +687,7 @@ var ProvidersBlotoutWalletSdk = (function () {
|
|
687
687
|
const response = await fetchImpl(getURL('/cart/expired'), {
|
688
688
|
method: 'GET',
|
689
689
|
headers: getHeaders(),
|
690
|
+
credentials: 'include',
|
690
691
|
});
|
691
692
|
if (!response.ok) {
|
692
693
|
throw new Error(`Unable to get expired cart - ${response.status}: ${response.statusText}\n\n${await response.text()}`);
|
@@ -707,6 +708,7 @@ var ProvidersBlotoutWalletSdk = (function () {
|
|
707
708
|
method: 'POST',
|
708
709
|
headers: getHeaders(true),
|
709
710
|
body: JSON.stringify({ action }),
|
711
|
+
credentials: 'include',
|
710
712
|
});
|
711
713
|
if (!response.ok) {
|
712
714
|
throw new Error(`Error while recording user event - ${response.status}: ${response.statusText}\n\n${await response.text()}`);
|
@@ -722,6 +724,7 @@ var ProvidersBlotoutWalletSdk = (function () {
|
|
722
724
|
method: 'POST',
|
723
725
|
headers: getHeaders(true),
|
724
726
|
body: JSON.stringify({ email: normalized }),
|
727
|
+
credentials: 'include',
|
725
728
|
});
|
726
729
|
if (!response.ok) {
|
727
730
|
throw new Error(`Could not save email - ${response.status}: ${response.statusText}\n\n${await response.text()}`);
|
@@ -732,6 +735,7 @@ var ProvidersBlotoutWalletSdk = (function () {
|
|
732
735
|
const response = await fetchImpl(getURL(`/cart/restore/${encodeURIComponent(cartId)}`), {
|
733
736
|
method: 'POST',
|
734
737
|
headers: getHeaders(),
|
738
|
+
credentials: 'include',
|
735
739
|
});
|
736
740
|
if (!response.ok) {
|
737
741
|
throw new Error(`Could not update status in DB - ${response.status}: ${response.text}\n\n${await response.text()}`);
|
@@ -744,6 +748,7 @@ var ProvidersBlotoutWalletSdk = (function () {
|
|
744
748
|
const response = await fetchImpl(getURL('/cart/skip'), {
|
745
749
|
method: 'POST',
|
746
750
|
headers: getHeaders(),
|
751
|
+
credentials: 'include',
|
747
752
|
});
|
748
753
|
if (!response.ok) {
|
749
754
|
throw new Error(`Could not mark cart as skipped - ${response.status}: ${await response.text()}`);
|
@@ -1144,12 +1149,7 @@ var ProvidersBlotoutWalletSdk = (function () {
|
|
1144
1149
|
}
|
1145
1150
|
this.restoreResponse = await this.storeAPI.addItems(this.lastExpiredCart.items, this.lastExpiredCart.token);
|
1146
1151
|
const expiredCartId = this.lastExpiredCart.cartId;
|
1147
|
-
|
1148
|
-
// we log the error in the console and let the user continue. Since the
|
1149
|
-
// problem is probably in the `/cart/restore` endpoint, further attempts
|
1150
|
-
// would not resolve the problem, which would just increase the number
|
1151
|
-
// of failed calls and not solve the problem.
|
1152
|
-
await this.walletAPI.restoreCart(expiredCartId, this.silentRestore).catch(logger.error);
|
1152
|
+
await this.walletAPI.restoreCart(expiredCartId, this.silentRestore);
|
1153
1153
|
this.lastExpiredCart = undefined;
|
1154
1154
|
this.dispatchEvent(new CustomEvent('blotout-wallet-cart-restored', {
|
1155
1155
|
bubbles: true,
|
@@ -1166,35 +1166,37 @@ var ProvidersBlotoutWalletSdk = (function () {
|
|
1166
1166
|
if (this.state == 'restored') {
|
1167
1167
|
this.hideModal('restore');
|
1168
1168
|
}
|
1169
|
-
|
1170
|
-
|
1171
|
-
|
1172
|
-
|
1173
|
-
|
1174
|
-
|
1169
|
+
this.afterHandleRestore();
|
1170
|
+
}
|
1171
|
+
catch (e) {
|
1172
|
+
logger.error(e);
|
1173
|
+
await this.transitionTo('failed');
|
1174
|
+
}
|
1175
|
+
};
|
1176
|
+
this.afterHandleRestore = () => {
|
1177
|
+
if (this.afterRestore) {
|
1178
|
+
switch (this.afterRestore.action) {
|
1179
|
+
case 'refresh': {
|
1180
|
+
window.location.reload();
|
1181
|
+
break;
|
1182
|
+
}
|
1183
|
+
case 'redirect': {
|
1184
|
+
try {
|
1185
|
+
window.location.href = new URL(this.afterRestore.url, window.location.href).toString();
|
1175
1186
|
}
|
1176
|
-
|
1177
|
-
|
1178
|
-
window.location.href = new URL(this.afterRestore.url, window.location.href).toString();
|
1179
|
-
}
|
1180
|
-
catch (e) {
|
1181
|
-
console.error('Invalid redirect URL', e);
|
1182
|
-
}
|
1183
|
-
break;
|
1187
|
+
catch (e) {
|
1188
|
+
console.error('Invalid redirect URL', e);
|
1184
1189
|
}
|
1185
|
-
|
1186
|
-
|
1187
|
-
|
1188
|
-
|
1189
|
-
|
1190
|
+
break;
|
1191
|
+
}
|
1192
|
+
case 'checkout': {
|
1193
|
+
const url = this.storeAPI.getCheckoutURL();
|
1194
|
+
if (url) {
|
1195
|
+
window.location.href = url.toString();
|
1190
1196
|
}
|
1191
1197
|
}
|
1192
1198
|
}
|
1193
1199
|
}
|
1194
|
-
catch (e) {
|
1195
|
-
logger.error(e);
|
1196
|
-
await this.transitionTo('failed');
|
1197
|
-
}
|
1198
1200
|
};
|
1199
1201
|
this.onDialogClick = () => {
|
1200
1202
|
if (this.state == 'loading') {
|
@@ -1307,7 +1309,7 @@ var ProvidersBlotoutWalletSdk = (function () {
|
|
1307
1309
|
this.lastExpiredCart = carts[0];
|
1308
1310
|
if (carts === null || carts === void 0 ? void 0 : carts.length) {
|
1309
1311
|
if (this.silentRestore) {
|
1310
|
-
this.restoreCart().catch(logger.error);
|
1312
|
+
this.restoreCart().then(this.afterHandleRestore).catch(logger.error);
|
1311
1313
|
}
|
1312
1314
|
else if (!this.isPopUpDismissed) {
|
1313
1315
|
this.showModal();
|
package/index.mjs
CHANGED
@@ -684,6 +684,7 @@ const createWalletAPI = ({ fetch: fetchImpl = window.fetch, baseURL, userId, sto
|
|
684
684
|
const response = await fetchImpl(getURL('/cart/expired'), {
|
685
685
|
method: 'GET',
|
686
686
|
headers: getHeaders(),
|
687
|
+
credentials: 'include',
|
687
688
|
});
|
688
689
|
if (!response.ok) {
|
689
690
|
throw new Error(`Unable to get expired cart - ${response.status}: ${response.statusText}\n\n${await response.text()}`);
|
@@ -704,6 +705,7 @@ const createWalletAPI = ({ fetch: fetchImpl = window.fetch, baseURL, userId, sto
|
|
704
705
|
method: 'POST',
|
705
706
|
headers: getHeaders(true),
|
706
707
|
body: JSON.stringify({ action }),
|
708
|
+
credentials: 'include',
|
707
709
|
});
|
708
710
|
if (!response.ok) {
|
709
711
|
throw new Error(`Error while recording user event - ${response.status}: ${response.statusText}\n\n${await response.text()}`);
|
@@ -719,6 +721,7 @@ const createWalletAPI = ({ fetch: fetchImpl = window.fetch, baseURL, userId, sto
|
|
719
721
|
method: 'POST',
|
720
722
|
headers: getHeaders(true),
|
721
723
|
body: JSON.stringify({ email: normalized }),
|
724
|
+
credentials: 'include',
|
722
725
|
});
|
723
726
|
if (!response.ok) {
|
724
727
|
throw new Error(`Could not save email - ${response.status}: ${response.statusText}\n\n${await response.text()}`);
|
@@ -729,6 +732,7 @@ const createWalletAPI = ({ fetch: fetchImpl = window.fetch, baseURL, userId, sto
|
|
729
732
|
const response = await fetchImpl(getURL(`/cart/restore/${encodeURIComponent(cartId)}`), {
|
730
733
|
method: 'POST',
|
731
734
|
headers: getHeaders(),
|
735
|
+
credentials: 'include',
|
732
736
|
});
|
733
737
|
if (!response.ok) {
|
734
738
|
throw new Error(`Could not update status in DB - ${response.status}: ${response.text}\n\n${await response.text()}`);
|
@@ -741,6 +745,7 @@ const createWalletAPI = ({ fetch: fetchImpl = window.fetch, baseURL, userId, sto
|
|
741
745
|
const response = await fetchImpl(getURL('/cart/skip'), {
|
742
746
|
method: 'POST',
|
743
747
|
headers: getHeaders(),
|
748
|
+
credentials: 'include',
|
744
749
|
});
|
745
750
|
if (!response.ok) {
|
746
751
|
throw new Error(`Could not mark cart as skipped - ${response.status}: ${await response.text()}`);
|
@@ -1141,12 +1146,7 @@ let BlotoutWallet = class BlotoutWallet extends i$2 {
|
|
1141
1146
|
}
|
1142
1147
|
this.restoreResponse = await this.storeAPI.addItems(this.lastExpiredCart.items, this.lastExpiredCart.token);
|
1143
1148
|
const expiredCartId = this.lastExpiredCart.cartId;
|
1144
|
-
|
1145
|
-
// we log the error in the console and let the user continue. Since the
|
1146
|
-
// problem is probably in the `/cart/restore` endpoint, further attempts
|
1147
|
-
// would not resolve the problem, which would just increase the number
|
1148
|
-
// of failed calls and not solve the problem.
|
1149
|
-
await this.walletAPI.restoreCart(expiredCartId, this.silentRestore).catch(logger.error);
|
1149
|
+
await this.walletAPI.restoreCart(expiredCartId, this.silentRestore);
|
1150
1150
|
this.lastExpiredCart = undefined;
|
1151
1151
|
this.dispatchEvent(new CustomEvent('blotout-wallet-cart-restored', {
|
1152
1152
|
bubbles: true,
|
@@ -1163,35 +1163,37 @@ let BlotoutWallet = class BlotoutWallet extends i$2 {
|
|
1163
1163
|
if (this.state == 'restored') {
|
1164
1164
|
this.hideModal('restore');
|
1165
1165
|
}
|
1166
|
-
|
1167
|
-
|
1168
|
-
|
1169
|
-
|
1170
|
-
|
1171
|
-
|
1166
|
+
this.afterHandleRestore();
|
1167
|
+
}
|
1168
|
+
catch (e) {
|
1169
|
+
logger.error(e);
|
1170
|
+
await this.transitionTo('failed');
|
1171
|
+
}
|
1172
|
+
};
|
1173
|
+
this.afterHandleRestore = () => {
|
1174
|
+
if (this.afterRestore) {
|
1175
|
+
switch (this.afterRestore.action) {
|
1176
|
+
case 'refresh': {
|
1177
|
+
window.location.reload();
|
1178
|
+
break;
|
1179
|
+
}
|
1180
|
+
case 'redirect': {
|
1181
|
+
try {
|
1182
|
+
window.location.href = new URL(this.afterRestore.url, window.location.href).toString();
|
1172
1183
|
}
|
1173
|
-
|
1174
|
-
|
1175
|
-
window.location.href = new URL(this.afterRestore.url, window.location.href).toString();
|
1176
|
-
}
|
1177
|
-
catch (e) {
|
1178
|
-
console.error('Invalid redirect URL', e);
|
1179
|
-
}
|
1180
|
-
break;
|
1184
|
+
catch (e) {
|
1185
|
+
console.error('Invalid redirect URL', e);
|
1181
1186
|
}
|
1182
|
-
|
1183
|
-
|
1184
|
-
|
1185
|
-
|
1186
|
-
|
1187
|
+
break;
|
1188
|
+
}
|
1189
|
+
case 'checkout': {
|
1190
|
+
const url = this.storeAPI.getCheckoutURL();
|
1191
|
+
if (url) {
|
1192
|
+
window.location.href = url.toString();
|
1187
1193
|
}
|
1188
1194
|
}
|
1189
1195
|
}
|
1190
1196
|
}
|
1191
|
-
catch (e) {
|
1192
|
-
logger.error(e);
|
1193
|
-
await this.transitionTo('failed');
|
1194
|
-
}
|
1195
1197
|
};
|
1196
1198
|
this.onDialogClick = () => {
|
1197
1199
|
if (this.state == 'loading') {
|
@@ -1304,7 +1306,7 @@ let BlotoutWallet = class BlotoutWallet extends i$2 {
|
|
1304
1306
|
this.lastExpiredCart = carts[0];
|
1305
1307
|
if (carts === null || carts === void 0 ? void 0 : carts.length) {
|
1306
1308
|
if (this.silentRestore) {
|
1307
|
-
this.restoreCart().catch(logger.error);
|
1309
|
+
this.restoreCart().then(this.afterHandleRestore).catch(logger.error);
|
1308
1310
|
}
|
1309
1311
|
else if (!this.isPopUpDismissed) {
|
1310
1312
|
this.showModal();
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@blotoutio/providers-blotout-wallet-sdk",
|
3
|
-
"version": "1.
|
3
|
+
"version": "1.14.0",
|
4
4
|
"description": "Blotout Wallet SDK for EdgeTag",
|
5
5
|
"author": "Blotout",
|
6
6
|
"license": "MIT",
|
@@ -10,6 +10,7 @@
|
|
10
10
|
},
|
11
11
|
"main": "./index.cjs.js",
|
12
12
|
"module": "./index.mjs",
|
13
|
+
"types": "./index.d.ts",
|
13
14
|
"exports": {
|
14
15
|
".": {
|
15
16
|
"require": "./index.cjs.js",
|
@@ -42,6 +43,7 @@
|
|
42
43
|
"index.js",
|
43
44
|
"index.cjs.js",
|
44
45
|
"index.mjs",
|
46
|
+
"index.d.ts",
|
45
47
|
"core.js",
|
46
48
|
"core.cjs.js",
|
47
49
|
"core.mjs",
|
package/ui.cjs.js
CHANGED
@@ -775,12 +775,7 @@ let BlotoutWallet = class BlotoutWallet extends i$2 {
|
|
775
775
|
}
|
776
776
|
this.restoreResponse = await this.storeAPI.addItems(this.lastExpiredCart.items, this.lastExpiredCart.token);
|
777
777
|
const expiredCartId = this.lastExpiredCart.cartId;
|
778
|
-
|
779
|
-
// we log the error in the console and let the user continue. Since the
|
780
|
-
// problem is probably in the `/cart/restore` endpoint, further attempts
|
781
|
-
// would not resolve the problem, which would just increase the number
|
782
|
-
// of failed calls and not solve the problem.
|
783
|
-
await this.walletAPI.restoreCart(expiredCartId, this.silentRestore).catch(logger.error);
|
778
|
+
await this.walletAPI.restoreCart(expiredCartId, this.silentRestore);
|
784
779
|
this.lastExpiredCart = undefined;
|
785
780
|
this.dispatchEvent(new CustomEvent('blotout-wallet-cart-restored', {
|
786
781
|
bubbles: true,
|
@@ -797,35 +792,37 @@ let BlotoutWallet = class BlotoutWallet extends i$2 {
|
|
797
792
|
if (this.state == 'restored') {
|
798
793
|
this.hideModal('restore');
|
799
794
|
}
|
800
|
-
|
801
|
-
|
802
|
-
|
803
|
-
|
804
|
-
|
805
|
-
|
795
|
+
this.afterHandleRestore();
|
796
|
+
}
|
797
|
+
catch (e) {
|
798
|
+
logger.error(e);
|
799
|
+
await this.transitionTo('failed');
|
800
|
+
}
|
801
|
+
};
|
802
|
+
this.afterHandleRestore = () => {
|
803
|
+
if (this.afterRestore) {
|
804
|
+
switch (this.afterRestore.action) {
|
805
|
+
case 'refresh': {
|
806
|
+
window.location.reload();
|
807
|
+
break;
|
808
|
+
}
|
809
|
+
case 'redirect': {
|
810
|
+
try {
|
811
|
+
window.location.href = new URL(this.afterRestore.url, window.location.href).toString();
|
806
812
|
}
|
807
|
-
|
808
|
-
|
809
|
-
window.location.href = new URL(this.afterRestore.url, window.location.href).toString();
|
810
|
-
}
|
811
|
-
catch (e) {
|
812
|
-
console.error('Invalid redirect URL', e);
|
813
|
-
}
|
814
|
-
break;
|
813
|
+
catch (e) {
|
814
|
+
console.error('Invalid redirect URL', e);
|
815
815
|
}
|
816
|
-
|
817
|
-
|
818
|
-
|
819
|
-
|
820
|
-
|
816
|
+
break;
|
817
|
+
}
|
818
|
+
case 'checkout': {
|
819
|
+
const url = this.storeAPI.getCheckoutURL();
|
820
|
+
if (url) {
|
821
|
+
window.location.href = url.toString();
|
821
822
|
}
|
822
823
|
}
|
823
824
|
}
|
824
825
|
}
|
825
|
-
catch (e) {
|
826
|
-
logger.error(e);
|
827
|
-
await this.transitionTo('failed');
|
828
|
-
}
|
829
826
|
};
|
830
827
|
this.onDialogClick = () => {
|
831
828
|
if (this.state == 'loading') {
|
@@ -938,7 +935,7 @@ let BlotoutWallet = class BlotoutWallet extends i$2 {
|
|
938
935
|
this.lastExpiredCart = carts[0];
|
939
936
|
if (carts === null || carts === void 0 ? void 0 : carts.length) {
|
940
937
|
if (this.silentRestore) {
|
941
|
-
this.restoreCart().catch(logger.error);
|
938
|
+
this.restoreCart().then(this.afterHandleRestore).catch(logger.error);
|
942
939
|
}
|
943
940
|
else if (!this.isPopUpDismissed) {
|
944
941
|
this.showModal();
|
package/ui.js
CHANGED
@@ -776,12 +776,7 @@
|
|
776
776
|
}
|
777
777
|
this.restoreResponse = await this.storeAPI.addItems(this.lastExpiredCart.items, this.lastExpiredCart.token);
|
778
778
|
const expiredCartId = this.lastExpiredCart.cartId;
|
779
|
-
|
780
|
-
// we log the error in the console and let the user continue. Since the
|
781
|
-
// problem is probably in the `/cart/restore` endpoint, further attempts
|
782
|
-
// would not resolve the problem, which would just increase the number
|
783
|
-
// of failed calls and not solve the problem.
|
784
|
-
await this.walletAPI.restoreCart(expiredCartId, this.silentRestore).catch(logger.error);
|
779
|
+
await this.walletAPI.restoreCart(expiredCartId, this.silentRestore);
|
785
780
|
this.lastExpiredCart = undefined;
|
786
781
|
this.dispatchEvent(new CustomEvent('blotout-wallet-cart-restored', {
|
787
782
|
bubbles: true,
|
@@ -798,35 +793,37 @@
|
|
798
793
|
if (this.state == 'restored') {
|
799
794
|
this.hideModal('restore');
|
800
795
|
}
|
801
|
-
|
802
|
-
|
803
|
-
|
804
|
-
|
805
|
-
|
806
|
-
|
796
|
+
this.afterHandleRestore();
|
797
|
+
}
|
798
|
+
catch (e) {
|
799
|
+
logger.error(e);
|
800
|
+
await this.transitionTo('failed');
|
801
|
+
}
|
802
|
+
};
|
803
|
+
this.afterHandleRestore = () => {
|
804
|
+
if (this.afterRestore) {
|
805
|
+
switch (this.afterRestore.action) {
|
806
|
+
case 'refresh': {
|
807
|
+
window.location.reload();
|
808
|
+
break;
|
809
|
+
}
|
810
|
+
case 'redirect': {
|
811
|
+
try {
|
812
|
+
window.location.href = new URL(this.afterRestore.url, window.location.href).toString();
|
807
813
|
}
|
808
|
-
|
809
|
-
|
810
|
-
window.location.href = new URL(this.afterRestore.url, window.location.href).toString();
|
811
|
-
}
|
812
|
-
catch (e) {
|
813
|
-
console.error('Invalid redirect URL', e);
|
814
|
-
}
|
815
|
-
break;
|
814
|
+
catch (e) {
|
815
|
+
console.error('Invalid redirect URL', e);
|
816
816
|
}
|
817
|
-
|
818
|
-
|
819
|
-
|
820
|
-
|
821
|
-
|
817
|
+
break;
|
818
|
+
}
|
819
|
+
case 'checkout': {
|
820
|
+
const url = this.storeAPI.getCheckoutURL();
|
821
|
+
if (url) {
|
822
|
+
window.location.href = url.toString();
|
822
823
|
}
|
823
824
|
}
|
824
825
|
}
|
825
826
|
}
|
826
|
-
catch (e) {
|
827
|
-
logger.error(e);
|
828
|
-
await this.transitionTo('failed');
|
829
|
-
}
|
830
827
|
};
|
831
828
|
this.onDialogClick = () => {
|
832
829
|
if (this.state == 'loading') {
|
@@ -939,7 +936,7 @@
|
|
939
936
|
this.lastExpiredCart = carts[0];
|
940
937
|
if (carts === null || carts === void 0 ? void 0 : carts.length) {
|
941
938
|
if (this.silentRestore) {
|
942
|
-
this.restoreCart().catch(logger.error);
|
939
|
+
this.restoreCart().then(this.afterHandleRestore).catch(logger.error);
|
943
940
|
}
|
944
941
|
else if (!this.isPopUpDismissed) {
|
945
942
|
this.showModal();
|
package/ui.mjs
CHANGED
@@ -773,12 +773,7 @@ let BlotoutWallet = class BlotoutWallet extends i$2 {
|
|
773
773
|
}
|
774
774
|
this.restoreResponse = await this.storeAPI.addItems(this.lastExpiredCart.items, this.lastExpiredCart.token);
|
775
775
|
const expiredCartId = this.lastExpiredCart.cartId;
|
776
|
-
|
777
|
-
// we log the error in the console and let the user continue. Since the
|
778
|
-
// problem is probably in the `/cart/restore` endpoint, further attempts
|
779
|
-
// would not resolve the problem, which would just increase the number
|
780
|
-
// of failed calls and not solve the problem.
|
781
|
-
await this.walletAPI.restoreCart(expiredCartId, this.silentRestore).catch(logger.error);
|
776
|
+
await this.walletAPI.restoreCart(expiredCartId, this.silentRestore);
|
782
777
|
this.lastExpiredCart = undefined;
|
783
778
|
this.dispatchEvent(new CustomEvent('blotout-wallet-cart-restored', {
|
784
779
|
bubbles: true,
|
@@ -795,35 +790,37 @@ let BlotoutWallet = class BlotoutWallet extends i$2 {
|
|
795
790
|
if (this.state == 'restored') {
|
796
791
|
this.hideModal('restore');
|
797
792
|
}
|
798
|
-
|
799
|
-
|
800
|
-
|
801
|
-
|
802
|
-
|
803
|
-
|
793
|
+
this.afterHandleRestore();
|
794
|
+
}
|
795
|
+
catch (e) {
|
796
|
+
logger.error(e);
|
797
|
+
await this.transitionTo('failed');
|
798
|
+
}
|
799
|
+
};
|
800
|
+
this.afterHandleRestore = () => {
|
801
|
+
if (this.afterRestore) {
|
802
|
+
switch (this.afterRestore.action) {
|
803
|
+
case 'refresh': {
|
804
|
+
window.location.reload();
|
805
|
+
break;
|
806
|
+
}
|
807
|
+
case 'redirect': {
|
808
|
+
try {
|
809
|
+
window.location.href = new URL(this.afterRestore.url, window.location.href).toString();
|
804
810
|
}
|
805
|
-
|
806
|
-
|
807
|
-
window.location.href = new URL(this.afterRestore.url, window.location.href).toString();
|
808
|
-
}
|
809
|
-
catch (e) {
|
810
|
-
console.error('Invalid redirect URL', e);
|
811
|
-
}
|
812
|
-
break;
|
811
|
+
catch (e) {
|
812
|
+
console.error('Invalid redirect URL', e);
|
813
813
|
}
|
814
|
-
|
815
|
-
|
816
|
-
|
817
|
-
|
818
|
-
|
814
|
+
break;
|
815
|
+
}
|
816
|
+
case 'checkout': {
|
817
|
+
const url = this.storeAPI.getCheckoutURL();
|
818
|
+
if (url) {
|
819
|
+
window.location.href = url.toString();
|
819
820
|
}
|
820
821
|
}
|
821
822
|
}
|
822
823
|
}
|
823
|
-
catch (e) {
|
824
|
-
logger.error(e);
|
825
|
-
await this.transitionTo('failed');
|
826
|
-
}
|
827
824
|
};
|
828
825
|
this.onDialogClick = () => {
|
829
826
|
if (this.state == 'loading') {
|
@@ -936,7 +933,7 @@ let BlotoutWallet = class BlotoutWallet extends i$2 {
|
|
936
933
|
this.lastExpiredCart = carts[0];
|
937
934
|
if (carts === null || carts === void 0 ? void 0 : carts.length) {
|
938
935
|
if (this.silentRestore) {
|
939
|
-
this.restoreCart().catch(logger.error);
|
936
|
+
this.restoreCart().then(this.afterHandleRestore).catch(logger.error);
|
940
937
|
}
|
941
938
|
else if (!this.isPopUpDismissed) {
|
942
939
|
this.showModal();
|