@storepecker/storefront-core 2.3.0 → 2.3.2

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.
Files changed (45) hide show
  1. package/dist/api/index.cjs +78 -74
  2. package/dist/api/index.d.cts +7 -2
  3. package/dist/api/index.d.ts +7 -2
  4. package/dist/api/index.js +6 -6
  5. package/dist/{cart-XumsY-y0.d.cts → cart-B13IUuwP.d.cts} +3 -0
  6. package/dist/{cart-CfsntcpS.d.ts → cart-DOy6dICN.d.ts} +3 -0
  7. package/dist/checkout/index.cjs +40 -36
  8. package/dist/checkout/index.d.cts +7 -2
  9. package/dist/checkout/index.d.ts +7 -2
  10. package/dist/checkout/index.js +4 -4
  11. package/dist/{chunk-BHOXJGIE.js → chunk-27MTKBJL.js} +1 -1
  12. package/dist/chunk-3SYYP3XV.js +121 -0
  13. package/dist/{chunk-XLQAALMU.cjs → chunk-65Z7I5UP.cjs} +10 -10
  14. package/dist/{chunk-FMHR5ABF.cjs → chunk-CV6DWPYF.cjs} +28 -28
  15. package/dist/chunk-ECHV2JSY.cjs +130 -0
  16. package/dist/{chunk-B7FOXIZN.js → chunk-ELP23UGF.js} +27 -2
  17. package/dist/{chunk-7R2V4C7Q.js → chunk-ILVGYHNI.js} +2 -2
  18. package/dist/{chunk-N3ZCCKXV.cjs → chunk-JCOOINQF.cjs} +10 -10
  19. package/dist/{chunk-SABICUTC.cjs → chunk-NKJ4DF4D.cjs} +6 -6
  20. package/dist/{chunk-G3R7ZVAG.cjs → chunk-RDUT4W3B.cjs} +7 -7
  21. package/dist/{chunk-47XTPPII.cjs → chunk-TB72NPRM.cjs} +27 -1
  22. package/dist/{chunk-ERLBPVFK.js → chunk-U25T7M6S.js} +3 -2
  23. package/dist/{chunk-QBRME5AG.js → chunk-VJCAOV74.js} +1 -1
  24. package/dist/{chunk-GHABOHLA.js → chunk-VWFZZFZL.js} +1 -1
  25. package/dist/{chunk-C7ZJZEEN.js → chunk-WYXT5AAG.js} +1 -1
  26. package/dist/{chunk-A67PCF55.cjs → chunk-Y2CPMT34.cjs} +19 -18
  27. package/dist/{chunk-KKQKHG26.cjs → chunk-Y46EHRJQ.cjs} +3 -3
  28. package/dist/{chunk-YY77CUWX.js → chunk-ZGMLOLTC.js} +1 -1
  29. package/dist/components/index.cjs +5 -5
  30. package/dist/components/index.js +4 -4
  31. package/dist/hooks/index.cjs +32 -32
  32. package/dist/hooks/index.d.cts +1 -1
  33. package/dist/hooks/index.d.ts +1 -1
  34. package/dist/hooks/index.js +9 -9
  35. package/dist/models/index.d.cts +1 -1
  36. package/dist/models/index.d.ts +1 -1
  37. package/dist/store/index.cjs +8 -8
  38. package/dist/store/index.d.cts +1 -1
  39. package/dist/store/index.d.ts +1 -1
  40. package/dist/store/index.js +3 -3
  41. package/dist/utils/index.d.cts +1 -1
  42. package/dist/utils/index.d.ts +1 -1
  43. package/package.json +1 -1
  44. package/dist/chunk-JWKDXFS4.js +0 -61
  45. package/dist/chunk-ZO2HREQL.cjs +0 -69
@@ -1,10 +1,10 @@
1
1
  'use strict';
2
2
 
3
- var chunkXLQAALMU_cjs = require('../chunk-XLQAALMU.cjs');
4
- var chunkFMHR5ABF_cjs = require('../chunk-FMHR5ABF.cjs');
3
+ var chunk65Z7I5UP_cjs = require('../chunk-65Z7I5UP.cjs');
4
+ var chunkCV6DWPYF_cjs = require('../chunk-CV6DWPYF.cjs');
5
5
  var chunkK44JZ5NL_cjs = require('../chunk-K44JZ5NL.cjs');
6
- var chunk47XTPPII_cjs = require('../chunk-47XTPPII.cjs');
7
- require('../chunk-ZO2HREQL.cjs');
6
+ var chunkTB72NPRM_cjs = require('../chunk-TB72NPRM.cjs');
7
+ require('../chunk-ECHV2JSY.cjs');
8
8
  require('../chunk-BBRXE57K.cjs');
9
9
  require('../chunk-NE3ZHELZ.cjs');
10
10
  require('../chunk-N3CTXRFT.cjs');
@@ -48,7 +48,7 @@ function calculateCartTotals(cart) {
48
48
  // src/checkout/payment-status.ts
49
49
  async function checkPhonepeReturnStatus(transactionId, callbacks) {
50
50
  try {
51
- const response = await chunkFMHR5ABF_cjs.checkPhonepePaymentStatus(transactionId);
51
+ const response = await chunkCV6DWPYF_cjs.checkPhonepePaymentStatus(transactionId);
52
52
  if (response.data.success) {
53
53
  callbacks.onSuccess(void 0);
54
54
  } else {
@@ -61,8 +61,8 @@ async function checkPhonepeReturnStatus(transactionId, callbacks) {
61
61
  async function checkPhonepeReturnStatusWithOrder(transactionId, orderNumber, callbacks) {
62
62
  try {
63
63
  const [paymentResponse, orderResponse] = await Promise.all([
64
- chunkFMHR5ABF_cjs.checkPhonepePaymentStatus(transactionId),
65
- chunkFMHR5ABF_cjs.getOrderDetailsByNumber(orderNumber)
64
+ chunkCV6DWPYF_cjs.checkPhonepePaymentStatus(transactionId),
65
+ chunkCV6DWPYF_cjs.getOrderDetailsByNumber(orderNumber)
66
66
  ]);
67
67
  const order = orderResponse.data;
68
68
  callbacks.onOrderLoaded?.(order);
@@ -79,12 +79,12 @@ async function checkPhonepeReturnStatusWithOrder(transactionId, orderNumber, cal
79
79
  }
80
80
  async function checkStripeReturnStatus(sessionId, orderNumber, paymentLinkUrl, callbacks, options) {
81
81
  try {
82
- const getStatus = options?.isPublic ? chunkFMHR5ABF_cjs.getStripePaymentStatusPublic : chunkFMHR5ABF_cjs.getStripePaymentStatus;
82
+ const getStatus = options?.isPublic ? chunkCV6DWPYF_cjs.getStripePaymentStatusPublic : chunkCV6DWPYF_cjs.getStripePaymentStatus;
83
83
  const response = await getStatus(sessionId, orderNumber, paymentLinkUrl);
84
84
  const data = response.data;
85
85
  if (data.payment_status === "paid" || data.status === "complete") {
86
86
  try {
87
- const orderResponse = await chunkFMHR5ABF_cjs.getOrderDetailsByNumber(orderNumber);
87
+ const orderResponse = await chunkCV6DWPYF_cjs.getOrderDetailsByNumber(orderNumber);
88
88
  const order = orderResponse.data;
89
89
  callbacks.onOrderLoaded?.(order);
90
90
  chunkK44JZ5NL_cjs.pixelEvents.purchase(order);
@@ -102,10 +102,10 @@ async function checkStripeReturnStatus(sessionId, orderNumber, paymentLinkUrl, c
102
102
  }
103
103
  async function checkTabbyReturnStatus(orderNumber, callbacks) {
104
104
  try {
105
- const response = await chunkFMHR5ABF_cjs.verifyTabbyPayment(orderNumber);
105
+ const response = await chunkCV6DWPYF_cjs.verifyTabbyPayment(orderNumber);
106
106
  if (response.data.order_status === "paid" || response.data.order_status === "confirmed") {
107
107
  try {
108
- const orderResponse = await chunkFMHR5ABF_cjs.getOrderDetailsByNumber(orderNumber);
108
+ const orderResponse = await chunkCV6DWPYF_cjs.getOrderDetailsByNumber(orderNumber);
109
109
  const order = orderResponse.data;
110
110
  callbacks.onOrderLoaded?.(order);
111
111
  chunkK44JZ5NL_cjs.pixelEvents.purchase(order);
@@ -124,103 +124,107 @@ async function checkTabbyReturnStatus(orderNumber, callbacks) {
124
124
 
125
125
  Object.defineProperty(exports, "applyCheckoutCoupon", {
126
126
  enumerable: true,
127
- get: function () { return chunkXLQAALMU_cjs.applyCheckoutCoupon; }
127
+ get: function () { return chunk65Z7I5UP_cjs.applyCheckoutCoupon; }
128
128
  });
129
129
  Object.defineProperty(exports, "fetchAppliedCoupon", {
130
130
  enumerable: true,
131
- get: function () { return chunkXLQAALMU_cjs.fetchAppliedCoupon; }
131
+ get: function () { return chunk65Z7I5UP_cjs.fetchAppliedCoupon; }
132
132
  });
133
133
  Object.defineProperty(exports, "fetchAvailableCoupons", {
134
134
  enumerable: true,
135
- get: function () { return chunkXLQAALMU_cjs.fetchAvailableCoupons; }
135
+ get: function () { return chunk65Z7I5UP_cjs.fetchAvailableCoupons; }
136
136
  });
137
137
  Object.defineProperty(exports, "handleCODPayment", {
138
138
  enumerable: true,
139
- get: function () { return chunkXLQAALMU_cjs.handleCODPayment; }
139
+ get: function () { return chunk65Z7I5UP_cjs.handleCODPayment; }
140
140
  });
141
141
  Object.defineProperty(exports, "handlePhonepePayment", {
142
142
  enumerable: true,
143
- get: function () { return chunkXLQAALMU_cjs.handlePhonepePayment; }
143
+ get: function () { return chunk65Z7I5UP_cjs.handlePhonepePayment; }
144
144
  });
145
145
  Object.defineProperty(exports, "handleRazorpayFail", {
146
146
  enumerable: true,
147
- get: function () { return chunkXLQAALMU_cjs.handleRazorpayFail; }
147
+ get: function () { return chunk65Z7I5UP_cjs.handleRazorpayFail; }
148
148
  });
149
149
  Object.defineProperty(exports, "handleRazorpaySuccess", {
150
150
  enumerable: true,
151
- get: function () { return chunkXLQAALMU_cjs.handleRazorpaySuccess; }
151
+ get: function () { return chunk65Z7I5UP_cjs.handleRazorpaySuccess; }
152
152
  });
153
153
  Object.defineProperty(exports, "handleStripePayment", {
154
154
  enumerable: true,
155
- get: function () { return chunkXLQAALMU_cjs.handleStripePayment; }
155
+ get: function () { return chunk65Z7I5UP_cjs.handleStripePayment; }
156
156
  });
157
157
  Object.defineProperty(exports, "handleStripeSuccess", {
158
158
  enumerable: true,
159
- get: function () { return chunkXLQAALMU_cjs.handleStripeSuccess; }
159
+ get: function () { return chunk65Z7I5UP_cjs.handleStripeSuccess; }
160
160
  });
161
161
  Object.defineProperty(exports, "handleTabbyPayment", {
162
162
  enumerable: true,
163
- get: function () { return chunkXLQAALMU_cjs.handleTabbyPayment; }
163
+ get: function () { return chunk65Z7I5UP_cjs.handleTabbyPayment; }
164
164
  });
165
165
  Object.defineProperty(exports, "openRazorpayCheckout", {
166
166
  enumerable: true,
167
- get: function () { return chunkXLQAALMU_cjs.openRazorpayCheckout; }
167
+ get: function () { return chunk65Z7I5UP_cjs.openRazorpayCheckout; }
168
168
  });
169
169
  Object.defineProperty(exports, "processPayment", {
170
170
  enumerable: true,
171
- get: function () { return chunkXLQAALMU_cjs.processPayment; }
171
+ get: function () { return chunk65Z7I5UP_cjs.processPayment; }
172
172
  });
173
173
  Object.defineProperty(exports, "removeCheckoutCoupon", {
174
174
  enumerable: true,
175
- get: function () { return chunkXLQAALMU_cjs.removeCheckoutCoupon; }
175
+ get: function () { return chunk65Z7I5UP_cjs.removeCheckoutCoupon; }
176
176
  });
177
177
  Object.defineProperty(exports, "IP_API_CACHE_KEY", {
178
178
  enumerable: true,
179
- get: function () { return chunk47XTPPII_cjs.IP_API_CACHE_KEY; }
179
+ get: function () { return chunkTB72NPRM_cjs.IP_API_CACHE_KEY; }
180
180
  });
181
181
  Object.defineProperty(exports, "addressFormInitialValues", {
182
182
  enumerable: true,
183
- get: function () { return chunk47XTPPII_cjs.addressFormInitialValues; }
183
+ get: function () { return chunkTB72NPRM_cjs.addressFormInitialValues; }
184
184
  });
185
185
  Object.defineProperty(exports, "addressValidationSchema", {
186
186
  enumerable: true,
187
- get: function () { return chunk47XTPPII_cjs.addressValidationSchema; }
187
+ get: function () { return chunkTB72NPRM_cjs.addressValidationSchema; }
188
188
  });
189
189
  Object.defineProperty(exports, "buildAddressPayload", {
190
190
  enumerable: true,
191
- get: function () { return chunk47XTPPII_cjs.buildAddressPayload; }
191
+ get: function () { return chunkTB72NPRM_cjs.buildAddressPayload; }
192
192
  });
193
193
  Object.defineProperty(exports, "buildSubmitPayload", {
194
194
  enumerable: true,
195
- get: function () { return chunk47XTPPII_cjs.buildSubmitPayload; }
195
+ get: function () { return chunkTB72NPRM_cjs.buildSubmitPayload; }
196
196
  });
197
197
  Object.defineProperty(exports, "clearAddressFormSession", {
198
198
  enumerable: true,
199
- get: function () { return chunk47XTPPII_cjs.clearAddressFormSession; }
199
+ get: function () { return chunkTB72NPRM_cjs.clearAddressFormSession; }
200
200
  });
201
201
  Object.defineProperty(exports, "decodeAddress", {
202
202
  enumerable: true,
203
- get: function () { return chunk47XTPPII_cjs.decodeAddress; }
203
+ get: function () { return chunkTB72NPRM_cjs.decodeAddress; }
204
204
  });
205
205
  Object.defineProperty(exports, "encodeAddress", {
206
206
  enumerable: true,
207
- get: function () { return chunk47XTPPII_cjs.encodeAddress; }
207
+ get: function () { return chunkTB72NPRM_cjs.encodeAddress; }
208
208
  });
209
209
  Object.defineProperty(exports, "isValidPhoneNumber", {
210
210
  enumerable: true,
211
- get: function () { return chunk47XTPPII_cjs.isValidPhoneNumber; }
211
+ get: function () { return chunkTB72NPRM_cjs.isValidPhoneNumber; }
212
212
  });
213
213
  Object.defineProperty(exports, "loadAddressFormFromSession", {
214
214
  enumerable: true,
215
- get: function () { return chunk47XTPPII_cjs.loadAddressFormFromSession; }
215
+ get: function () { return chunkTB72NPRM_cjs.loadAddressFormFromSession; }
216
216
  });
217
217
  Object.defineProperty(exports, "parseEditAddress", {
218
218
  enumerable: true,
219
- get: function () { return chunk47XTPPII_cjs.parseEditAddress; }
219
+ get: function () { return chunkTB72NPRM_cjs.parseEditAddress; }
220
+ });
221
+ Object.defineProperty(exports, "sanitizePhoneNumber", {
222
+ enumerable: true,
223
+ get: function () { return chunkTB72NPRM_cjs.sanitizePhoneNumber; }
220
224
  });
221
225
  Object.defineProperty(exports, "saveAddressFormToSession", {
222
226
  enumerable: true,
223
- get: function () { return chunk47XTPPII_cjs.saveAddressFormToSession; }
227
+ get: function () { return chunkTB72NPRM_cjs.saveAddressFormToSession; }
224
228
  });
225
229
  exports.calculateCartTotals = calculateCartTotals;
226
230
  exports.checkPhonepeReturnStatus = checkPhonepeReturnStatus;
@@ -1,5 +1,5 @@
1
1
  import * as Yup from 'yup';
2
- import { C as Cart, c as Coupon } from '../cart-XumsY-y0.cjs';
2
+ import { C as Cart, c as Coupon } from '../cart-B13IUuwP.cjs';
3
3
  import { O as Order } from '../orders-Dm5Dq02y.cjs';
4
4
  import '../product-Daxj09p9.cjs';
5
5
  import 'react-toastify';
@@ -21,6 +21,11 @@ interface AddressFormValues {
21
21
  customer_email: string;
22
22
  }
23
23
  declare const addressFormInitialValues: AddressFormValues;
24
+ /**
25
+ * Strip country calling code prefix and trim whitespace from a phone number.
26
+ * E.g. "+919876543210" with countryCode "IN" → "9876543210"
27
+ */
28
+ declare function sanitizePhoneNumber(input: string, countryCode: string): string;
24
29
  /**
25
30
  * Validates a phone number using libphonenumber-js
26
31
  */
@@ -248,4 +253,4 @@ declare function checkStripeReturnStatus(sessionId: string, orderNumber: number,
248
253
  */
249
254
  declare function checkTabbyReturnStatus(orderNumber: number, callbacks: PaymentStatusCallbacks): Promise<void>;
250
255
 
251
- export { type AddressFormValues, type CartTotals, type CouponCallbacks, IP_API_CACHE_KEY, type PaymentCallbacks, type PaymentStatusCallbacks, addressFormInitialValues, addressValidationSchema, applyCheckoutCoupon, buildAddressPayload, buildSubmitPayload, calculateCartTotals, checkPhonepeReturnStatus, checkPhonepeReturnStatusWithOrder, checkStripeReturnStatus, checkTabbyReturnStatus, clearAddressFormSession, decodeAddress, encodeAddress, fetchAppliedCoupon, fetchAvailableCoupons, handleCODPayment, handlePhonepePayment, handleRazorpayFail, handleRazorpaySuccess, handleStripePayment, handleStripeSuccess, handleTabbyPayment, isValidPhoneNumber, loadAddressFormFromSession, openRazorpayCheckout, parseEditAddress, processPayment, removeCheckoutCoupon, saveAddressFormToSession };
256
+ export { type AddressFormValues, type CartTotals, type CouponCallbacks, IP_API_CACHE_KEY, type PaymentCallbacks, type PaymentStatusCallbacks, addressFormInitialValues, addressValidationSchema, applyCheckoutCoupon, buildAddressPayload, buildSubmitPayload, calculateCartTotals, checkPhonepeReturnStatus, checkPhonepeReturnStatusWithOrder, checkStripeReturnStatus, checkTabbyReturnStatus, clearAddressFormSession, decodeAddress, encodeAddress, fetchAppliedCoupon, fetchAvailableCoupons, handleCODPayment, handlePhonepePayment, handleRazorpayFail, handleRazorpaySuccess, handleStripePayment, handleStripeSuccess, handleTabbyPayment, isValidPhoneNumber, loadAddressFormFromSession, openRazorpayCheckout, parseEditAddress, processPayment, removeCheckoutCoupon, sanitizePhoneNumber, saveAddressFormToSession };
@@ -1,5 +1,5 @@
1
1
  import * as Yup from 'yup';
2
- import { C as Cart, c as Coupon } from '../cart-CfsntcpS.js';
2
+ import { C as Cart, c as Coupon } from '../cart-DOy6dICN.js';
3
3
  import { O as Order } from '../orders-CvCa7XWm.js';
4
4
  import '../product-Daxj09p9.js';
5
5
  import 'react-toastify';
@@ -21,6 +21,11 @@ interface AddressFormValues {
21
21
  customer_email: string;
22
22
  }
23
23
  declare const addressFormInitialValues: AddressFormValues;
24
+ /**
25
+ * Strip country calling code prefix and trim whitespace from a phone number.
26
+ * E.g. "+919876543210" with countryCode "IN" → "9876543210"
27
+ */
28
+ declare function sanitizePhoneNumber(input: string, countryCode: string): string;
24
29
  /**
25
30
  * Validates a phone number using libphonenumber-js
26
31
  */
@@ -248,4 +253,4 @@ declare function checkStripeReturnStatus(sessionId: string, orderNumber: number,
248
253
  */
249
254
  declare function checkTabbyReturnStatus(orderNumber: number, callbacks: PaymentStatusCallbacks): Promise<void>;
250
255
 
251
- export { type AddressFormValues, type CartTotals, type CouponCallbacks, IP_API_CACHE_KEY, type PaymentCallbacks, type PaymentStatusCallbacks, addressFormInitialValues, addressValidationSchema, applyCheckoutCoupon, buildAddressPayload, buildSubmitPayload, calculateCartTotals, checkPhonepeReturnStatus, checkPhonepeReturnStatusWithOrder, checkStripeReturnStatus, checkTabbyReturnStatus, clearAddressFormSession, decodeAddress, encodeAddress, fetchAppliedCoupon, fetchAvailableCoupons, handleCODPayment, handlePhonepePayment, handleRazorpayFail, handleRazorpaySuccess, handleStripePayment, handleStripeSuccess, handleTabbyPayment, isValidPhoneNumber, loadAddressFormFromSession, openRazorpayCheckout, parseEditAddress, processPayment, removeCheckoutCoupon, saveAddressFormToSession };
256
+ export { type AddressFormValues, type CartTotals, type CouponCallbacks, IP_API_CACHE_KEY, type PaymentCallbacks, type PaymentStatusCallbacks, addressFormInitialValues, addressValidationSchema, applyCheckoutCoupon, buildAddressPayload, buildSubmitPayload, calculateCartTotals, checkPhonepeReturnStatus, checkPhonepeReturnStatusWithOrder, checkStripeReturnStatus, checkTabbyReturnStatus, clearAddressFormSession, decodeAddress, encodeAddress, fetchAppliedCoupon, fetchAvailableCoupons, handleCODPayment, handlePhonepePayment, handleRazorpayFail, handleRazorpaySuccess, handleStripePayment, handleStripeSuccess, handleTabbyPayment, isValidPhoneNumber, loadAddressFormFromSession, openRazorpayCheckout, parseEditAddress, processPayment, removeCheckoutCoupon, sanitizePhoneNumber, saveAddressFormToSession };
@@ -1,8 +1,8 @@
1
- export { applyCheckoutCoupon, fetchAppliedCoupon, fetchAvailableCoupons, handleCODPayment, handlePhonepePayment, handleRazorpayFail, handleRazorpaySuccess, handleStripePayment, handleStripeSuccess, handleTabbyPayment, openRazorpayCheckout, processPayment, removeCheckoutCoupon } from '../chunk-BHOXJGIE.js';
2
- import { checkPhonepePaymentStatus, getOrderDetailsByNumber, getStripePaymentStatusPublic, getStripePaymentStatus, verifyTabbyPayment } from '../chunk-GHABOHLA.js';
1
+ export { applyCheckoutCoupon, fetchAppliedCoupon, fetchAvailableCoupons, handleCODPayment, handlePhonepePayment, handleRazorpayFail, handleRazorpaySuccess, handleStripePayment, handleStripeSuccess, handleTabbyPayment, openRazorpayCheckout, processPayment, removeCheckoutCoupon } from '../chunk-27MTKBJL.js';
2
+ import { checkPhonepePaymentStatus, getOrderDetailsByNumber, getStripePaymentStatusPublic, getStripePaymentStatus, verifyTabbyPayment } from '../chunk-VWFZZFZL.js';
3
3
  import { pixelEvents } from '../chunk-WFDKKOO7.js';
4
- export { IP_API_CACHE_KEY, addressFormInitialValues, addressValidationSchema, buildAddressPayload, buildSubmitPayload, clearAddressFormSession, decodeAddress, encodeAddress, isValidPhoneNumber, loadAddressFormFromSession, parseEditAddress, saveAddressFormToSession } from '../chunk-B7FOXIZN.js';
5
- import '../chunk-JWKDXFS4.js';
4
+ export { IP_API_CACHE_KEY, addressFormInitialValues, addressValidationSchema, buildAddressPayload, buildSubmitPayload, clearAddressFormSession, decodeAddress, encodeAddress, isValidPhoneNumber, loadAddressFormFromSession, parseEditAddress, sanitizePhoneNumber, saveAddressFormToSession } from '../chunk-ELP23UGF.js';
5
+ import '../chunk-3SYYP3XV.js';
6
6
  import '../chunk-WEMNXIRS.js';
7
7
  import '../chunk-BQ256JKN.js';
8
8
  import '../chunk-JQMLHRWL.js';
@@ -1,4 +1,4 @@
1
- import { razorpayOrderSuccess, razorpayOrderFail, publicMakeCODOrder, makeCODOrder, stripeOrderSuccess, getCoupons, getAppliedCoupon, applyCoupon, removeCoupon } from './chunk-GHABOHLA.js';
1
+ import { razorpayOrderSuccess, razorpayOrderFail, publicMakeCODOrder, makeCODOrder, stripeOrderSuccess, getCoupons, getAppliedCoupon, applyCoupon, removeCoupon } from './chunk-VWFZZFZL.js';
2
2
  import { pixelEvents } from './chunk-WFDKKOO7.js';
3
3
  import { getCloudFront } from './chunk-JQMLHRWL.js';
4
4
  import { AxiosError } from 'axios';
@@ -0,0 +1,121 @@
1
+ import { auth_default } from './chunk-WEMNXIRS.js';
2
+ import { getPublicApiEndpoint, getStoreId } from './chunk-JQMLHRWL.js';
3
+ import axios from 'axios';
4
+ import { getCookie } from 'typescript-cookie';
5
+ import { jwtDecode } from 'jwt-decode';
6
+
7
+ var _instance = null;
8
+ var _isRefreshing = false;
9
+ var _refreshQueue = [];
10
+ var _onSessionExpired = null;
11
+ function setSessionExpiredCallback(cb) {
12
+ _onSessionExpired = cb;
13
+ }
14
+ function isTokenExpiringSoon(token) {
15
+ try {
16
+ const decoded = jwtDecode(token);
17
+ if (!decoded?.exp) return false;
18
+ const expiresAt = decoded.exp * 1e3;
19
+ return Date.now() > expiresAt - 6e4;
20
+ } catch {
21
+ return false;
22
+ }
23
+ }
24
+ async function refreshAccessToken(instance) {
25
+ const refresh = auth_default.getRefreshToken();
26
+ if (!refresh) return null;
27
+ try {
28
+ const response = await instance.post("/api/token/refresh/", { refresh });
29
+ const { access, refresh: newRefresh } = response.data;
30
+ auth_default.setAccessToken(access);
31
+ auth_default.setRefreshToken(newRefresh);
32
+ return access;
33
+ } catch {
34
+ return null;
35
+ }
36
+ }
37
+ function queuedRefresh(instance) {
38
+ if (_isRefreshing) {
39
+ return new Promise((resolve, reject) => {
40
+ _refreshQueue.push({ resolve, reject });
41
+ });
42
+ }
43
+ _isRefreshing = true;
44
+ return refreshAccessToken(instance).then((token) => {
45
+ _isRefreshing = false;
46
+ if (token) {
47
+ _refreshQueue.forEach((req) => req.resolve(token));
48
+ } else {
49
+ auth_default.removeTokens();
50
+ _onSessionExpired?.();
51
+ _refreshQueue.forEach(
52
+ (req) => req.reject(new Error("Session expired"))
53
+ );
54
+ }
55
+ _refreshQueue = [];
56
+ return token;
57
+ });
58
+ }
59
+ function createInstance() {
60
+ const baseURL = getPublicApiEndpoint();
61
+ if (!baseURL) {
62
+ throw new Error("Missing API endpoint. Call initConfig() first.");
63
+ }
64
+ axios.defaults.withCredentials = true;
65
+ const instance = axios.create({
66
+ baseURL,
67
+ withCredentials: true
68
+ });
69
+ const onRequestSuccess = async (config) => {
70
+ const csrftoken = getCookie("csrftoken");
71
+ let token = auth_default.getAccessToken();
72
+ if (token && isTokenExpiringSoon(token) && !config.url?.includes("/api/token/refresh/")) {
73
+ const newToken = await queuedRefresh(instance);
74
+ if (newToken) token = newToken;
75
+ }
76
+ config.headers["X-CSRFToken"] = csrftoken;
77
+ if (token) config.headers["Authorization"] = `Bearer ${token}`;
78
+ const storeId = getStoreId();
79
+ if (storeId) config.headers[""] = `Store ${storeId}`;
80
+ return config;
81
+ };
82
+ const onRequestFail = (error) => {
83
+ return Promise.reject(error);
84
+ };
85
+ instance.interceptors.request.use(onRequestSuccess, onRequestFail);
86
+ const onResponseSuccess = (response) => {
87
+ return response;
88
+ };
89
+ const onResponseFail = async (error) => {
90
+ const originalRequest = error.config;
91
+ if (error.response?.status === 401 && originalRequest && !originalRequest.url?.includes("/api/token/refresh/") && !originalRequest._retried) {
92
+ originalRequest._retried = true;
93
+ const newToken = await queuedRefresh(instance);
94
+ if (newToken) {
95
+ originalRequest.headers["Authorization"] = `Bearer ${newToken}`;
96
+ return instance(originalRequest);
97
+ }
98
+ return Promise.reject(error);
99
+ }
100
+ return Promise.reject(error);
101
+ };
102
+ instance.interceptors.response.use(onResponseSuccess, onResponseFail);
103
+ return instance;
104
+ }
105
+ function getHttpService() {
106
+ if (!_instance) {
107
+ _instance = createInstance();
108
+ }
109
+ return _instance;
110
+ }
111
+ function resetHttpService() {
112
+ _instance = null;
113
+ }
114
+ var httpService = new Proxy({}, {
115
+ get(_target, prop) {
116
+ return getHttpService()[prop];
117
+ }
118
+ });
119
+ var http_service_default = httpService;
120
+
121
+ export { getHttpService, http_service_default, resetHttpService, setSessionExpiredCallback };
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkFMHR5ABF_cjs = require('./chunk-FMHR5ABF.cjs');
3
+ var chunkCV6DWPYF_cjs = require('./chunk-CV6DWPYF.cjs');
4
4
  var chunkK44JZ5NL_cjs = require('./chunk-K44JZ5NL.cjs');
5
5
  var chunkN3CTXRFT_cjs = require('./chunk-N3CTXRFT.cjs');
6
6
  var axios = require('axios');
@@ -65,7 +65,7 @@ function openRazorpayCheckout(order, callbacks) {
65
65
  async function handleRazorpaySuccess(data, order, callbacks) {
66
66
  try {
67
67
  callbacks.onPaymentStart?.();
68
- await chunkFMHR5ABF_cjs.razorpayOrderSuccess(data);
68
+ await chunkCV6DWPYF_cjs.razorpayOrderSuccess(data);
69
69
  chunkK44JZ5NL_cjs.pixelEvents.purchase(order);
70
70
  chunkK44JZ5NL_cjs.pixelEvents.checkoutCompleted(order);
71
71
  callbacks.onCartReset();
@@ -78,7 +78,7 @@ async function handleRazorpaySuccess(data, order, callbacks) {
78
78
  }
79
79
  async function handleRazorpayFail(order, callbacks) {
80
80
  try {
81
- await chunkFMHR5ABF_cjs.razorpayOrderFail({
81
+ await chunkCV6DWPYF_cjs.razorpayOrderFail({
82
82
  order_id: order.id,
83
83
  razorpay_order_id: order.razorpay_order_id
84
84
  });
@@ -110,9 +110,9 @@ async function handleCODPayment(order, callbacks, options) {
110
110
  callbacks.onPaymentStart?.();
111
111
  chunkK44JZ5NL_cjs.pixelEvents.initiateCheckout(order, "cod");
112
112
  if (options?.isPublic) {
113
- await chunkFMHR5ABF_cjs.publicMakeCODOrder(order.order_number);
113
+ await chunkCV6DWPYF_cjs.publicMakeCODOrder(order.order_number);
114
114
  } else {
115
- await chunkFMHR5ABF_cjs.makeCODOrder(order.id);
115
+ await chunkCV6DWPYF_cjs.makeCODOrder(order.id);
116
116
  }
117
117
  chunkK44JZ5NL_cjs.pixelEvents.purchase(order);
118
118
  chunkK44JZ5NL_cjs.pixelEvents.checkoutCompleted(order);
@@ -140,7 +140,7 @@ function handleStripePayment(order, callbacks) {
140
140
  async function handleStripeSuccess(order, paymentIntentId, callbacks) {
141
141
  try {
142
142
  callbacks.onPaymentStart?.();
143
- await chunkFMHR5ABF_cjs.stripeOrderSuccess({
143
+ await chunkCV6DWPYF_cjs.stripeOrderSuccess({
144
144
  order_id: order.id,
145
145
  payment_intent_id: paymentIntentId
146
146
  });
@@ -174,12 +174,12 @@ function processPayment(order, paymentMethod, callbacks, options) {
174
174
  handlePhonepePayment(order, callbacks);
175
175
  }
176
176
  async function fetchAvailableCoupons() {
177
- const response = await chunkFMHR5ABF_cjs.getCoupons();
177
+ const response = await chunkCV6DWPYF_cjs.getCoupons();
178
178
  return response.data;
179
179
  }
180
180
  async function fetchAppliedCoupon() {
181
181
  try {
182
- const response = await chunkFMHR5ABF_cjs.getAppliedCoupon();
182
+ const response = await chunkCV6DWPYF_cjs.getAppliedCoupon();
183
183
  return response.data || null;
184
184
  } catch {
185
185
  return null;
@@ -187,7 +187,7 @@ async function fetchAppliedCoupon() {
187
187
  }
188
188
  async function applyCheckoutCoupon(code, callbacks) {
189
189
  try {
190
- const response = await chunkFMHR5ABF_cjs.applyCoupon(code);
190
+ const response = await chunkCV6DWPYF_cjs.applyCoupon(code);
191
191
  if (response.data?.coupon) {
192
192
  await callbacks.onCartRefresh();
193
193
  return response.data.coupon;
@@ -201,7 +201,7 @@ async function applyCheckoutCoupon(code, callbacks) {
201
201
  }
202
202
  }
203
203
  async function removeCheckoutCoupon(couponCode, callbacks) {
204
- await chunkFMHR5ABF_cjs.removeCoupon(couponCode);
204
+ await chunkCV6DWPYF_cjs.removeCoupon(couponCode);
205
205
  await callbacks.onCartRefresh();
206
206
  }
207
207
 
@@ -1,43 +1,43 @@
1
1
  'use strict';
2
2
 
3
- var chunkZO2HREQL_cjs = require('./chunk-ZO2HREQL.cjs');
3
+ var chunkECHV2JSY_cjs = require('./chunk-ECHV2JSY.cjs');
4
4
 
5
5
  // src/api/coupon.ts
6
6
  async function getCoupons() {
7
- return chunkZO2HREQL_cjs.http_service_default.get("/coupon/available/");
7
+ return chunkECHV2JSY_cjs.http_service_default.get("/coupon/available/");
8
8
  }
9
9
  async function applyCoupon(couponCode) {
10
- return chunkZO2HREQL_cjs.http_service_default.post("/coupon/use/", { coupon_code: couponCode });
10
+ return chunkECHV2JSY_cjs.http_service_default.post("/coupon/use/", { coupon_code: couponCode });
11
11
  }
12
12
  async function getAppliedCoupon() {
13
- return chunkZO2HREQL_cjs.http_service_default.get("/coupon/use/");
13
+ return chunkECHV2JSY_cjs.http_service_default.get("/coupon/use/");
14
14
  }
15
15
  async function removeCoupon(couponCode) {
16
- return chunkZO2HREQL_cjs.http_service_default.delete("/coupon/use/");
16
+ return chunkECHV2JSY_cjs.http_service_default.delete("/coupon/use/");
17
17
  }
18
18
 
19
19
  // src/api/orders.ts
20
20
  async function getOrders(url) {
21
- const response = await chunkZO2HREQL_cjs.http_service_default.get(url);
21
+ const response = await chunkECHV2JSY_cjs.http_service_default.get(url);
22
22
  return response.data;
23
23
  }
24
24
  async function getOrderDetails(orderId) {
25
- return chunkZO2HREQL_cjs.http_service_default.get("/customer/order/", {
25
+ return chunkECHV2JSY_cjs.http_service_default.get("/customer/order/", {
26
26
  params: { order_id: orderId }
27
27
  });
28
28
  }
29
29
  async function getOrderDetailsByNumber(orderNumber) {
30
- return chunkZO2HREQL_cjs.http_service_default.get("/customer/order/", {
30
+ return chunkECHV2JSY_cjs.http_service_default.get("/customer/order/", {
31
31
  params: { order_number: orderNumber }
32
32
  });
33
33
  }
34
34
  async function getPublicOrderDetailsByNumber(orderNumber) {
35
- return chunkZO2HREQL_cjs.http_service_default.get("/customer/public_order/", {
35
+ return chunkECHV2JSY_cjs.http_service_default.get("/customer/public_order/", {
36
36
  params: { order_number: orderNumber }
37
37
  });
38
38
  }
39
39
  async function placeOrder(address_id, redirect, isCod, stripeRedirect, tabbyRedirect) {
40
- return chunkZO2HREQL_cjs.http_service_default.post("/customer/order/", {
40
+ return chunkECHV2JSY_cjs.http_service_default.post("/customer/order/", {
41
41
  address_id,
42
42
  phonepe_redirect_url: redirect,
43
43
  is_cod: isCod,
@@ -46,7 +46,7 @@ async function placeOrder(address_id, redirect, isCod, stripeRedirect, tabbyRedi
46
46
  });
47
47
  }
48
48
  async function publicPlaceOrder(address, redirect, orderDetails, stripeRedirect, tabbyRedirect) {
49
- return chunkZO2HREQL_cjs.http_service_default.post("/customer/public_order/", {
49
+ return chunkECHV2JSY_cjs.http_service_default.post("/customer/public_order/", {
50
50
  address,
51
51
  phonepe_redirect_url: redirect,
52
52
  stripe_redirect_url: stripeRedirect,
@@ -55,30 +55,30 @@ async function publicPlaceOrder(address, redirect, orderDetails, stripeRedirect,
55
55
  });
56
56
  }
57
57
  async function updateOrder(orderDetails) {
58
- return chunkZO2HREQL_cjs.http_service_default.patch("/customer/order/", orderDetails);
58
+ return chunkECHV2JSY_cjs.http_service_default.patch("/customer/order/", orderDetails);
59
59
  }
60
60
  async function razorpayPublicOrderSuccess(orderDetails) {
61
- return chunkZO2HREQL_cjs.http_service_default.post("/payment/public-razorpay-order-success/", orderDetails);
61
+ return chunkECHV2JSY_cjs.http_service_default.post("/payment/public-razorpay-order-success/", orderDetails);
62
62
  }
63
63
  async function razorpayOrderSuccess(orderDetails) {
64
- return chunkZO2HREQL_cjs.http_service_default.post("/payment/razorpay-order-success/", orderDetails);
64
+ return chunkECHV2JSY_cjs.http_service_default.post("/payment/razorpay-order-success/", orderDetails);
65
65
  }
66
66
  async function razorpayOrderFail(orderDetails) {
67
- return chunkZO2HREQL_cjs.http_service_default.post("/payment/razorpay-order-fail/", orderDetails);
67
+ return chunkECHV2JSY_cjs.http_service_default.post("/payment/razorpay-order-fail/", orderDetails);
68
68
  }
69
69
  async function phonepePublicOrderSuccess(orderDetails) {
70
- return chunkZO2HREQL_cjs.http_service_default.post("/payment/public-phonepe-order-success/", orderDetails);
70
+ return chunkECHV2JSY_cjs.http_service_default.post("/payment/public-phonepe-order-success/", orderDetails);
71
71
  }
72
72
  async function phonepeOrderSuccess(orderDetails) {
73
- return chunkZO2HREQL_cjs.http_service_default.post("/payment/phonepe-order-success/", orderDetails);
73
+ return chunkECHV2JSY_cjs.http_service_default.post("/payment/phonepe-order-success/", orderDetails);
74
74
  }
75
75
  async function checkPhonepePaymentStatus(transactionId) {
76
- return chunkZO2HREQL_cjs.http_service_default.get("/payment/phonepe-order-success/", {
76
+ return chunkECHV2JSY_cjs.http_service_default.get("/payment/phonepe-order-success/", {
77
77
  params: { phonepe_transaction_id: transactionId }
78
78
  });
79
79
  }
80
80
  async function getStripePaymentStatus(stripeCheckoutSessionId, order_number, payment_link_id) {
81
- return chunkZO2HREQL_cjs.http_service_default.get("/payment/stripe-payment-status/", {
81
+ return chunkECHV2JSY_cjs.http_service_default.get("/payment/stripe-payment-status/", {
82
82
  params: {
83
83
  checkout_session_id: stripeCheckoutSessionId,
84
84
  order_number,
@@ -87,7 +87,7 @@ async function getStripePaymentStatus(stripeCheckoutSessionId, order_number, pay
87
87
  });
88
88
  }
89
89
  async function getStripePaymentStatusPublic(stripeCheckoutSessionId, order_number, payment_link_id) {
90
- return chunkZO2HREQL_cjs.http_service_default.get("/payment/public-stripe-payment-status/", {
90
+ return chunkECHV2JSY_cjs.http_service_default.get("/payment/public-stripe-payment-status/", {
91
91
  params: {
92
92
  checkout_session_id: stripeCheckoutSessionId,
93
93
  order_number,
@@ -96,28 +96,28 @@ async function getStripePaymentStatusPublic(stripeCheckoutSessionId, order_numbe
96
96
  });
97
97
  }
98
98
  async function stripePublicOrderSuccess(orderDetails) {
99
- return chunkZO2HREQL_cjs.http_service_default.post("/payment/public-stripe-order-success/", orderDetails);
99
+ return chunkECHV2JSY_cjs.http_service_default.post("/payment/public-stripe-order-success/", orderDetails);
100
100
  }
101
101
  async function stripeOrderSuccess(orderDetails) {
102
- return chunkZO2HREQL_cjs.http_service_default.post("/payment/stripe-order-success/", orderDetails);
102
+ return chunkECHV2JSY_cjs.http_service_default.post("/payment/stripe-order-success/", orderDetails);
103
103
  }
104
104
  async function stripeOrderFail(orderDetails) {
105
- return chunkZO2HREQL_cjs.http_service_default.post("/payment/stripe-order-fail/", orderDetails);
105
+ return chunkECHV2JSY_cjs.http_service_default.post("/payment/stripe-order-fail/", orderDetails);
106
106
  }
107
107
  async function makeCODOrder(orderId) {
108
- return chunkZO2HREQL_cjs.http_service_default.post("/customer/order_cod/", { order_id: orderId });
108
+ return chunkECHV2JSY_cjs.http_service_default.post("/customer/order_cod/", { order_id: orderId });
109
109
  }
110
110
  async function publicMakeCODOrder(orderNumber) {
111
- return chunkZO2HREQL_cjs.http_service_default.post("/customer/public_order_cod/", { order_number: orderNumber });
111
+ return chunkECHV2JSY_cjs.http_service_default.post("/customer/public_order_cod/", { order_number: orderNumber });
112
112
  }
113
113
  async function updateOrderCustomization(customizationInput) {
114
- return chunkZO2HREQL_cjs.http_service_default.post("/customer/product_personalize/", customizationInput);
114
+ return chunkECHV2JSY_cjs.http_service_default.post("/customer/product_personalize/", customizationInput);
115
115
  }
116
116
  async function uploadCustomizationImage(uploadForm) {
117
- return chunkZO2HREQL_cjs.http_service_default.post("/utils/upload_image", uploadForm);
117
+ return chunkECHV2JSY_cjs.http_service_default.post("/utils/upload_image", uploadForm);
118
118
  }
119
119
  async function verifyTabbyPayment(orderNumber) {
120
- return chunkZO2HREQL_cjs.http_service_default.get("/payment/tabby-payment-status/", {
120
+ return chunkECHV2JSY_cjs.http_service_default.get("/payment/tabby-payment-status/", {
121
121
  params: { order_number: orderNumber }
122
122
  });
123
123
  }